Last active
March 25, 2019 20:26
-
-
Save consolewitch/bf2498e98f88491bd81b23e9f2e7c872 to your computer and use it in GitHub Desktop.
Revisions
-
consolewitch revised this gist
Mar 25, 2019 . 1 changed file with 11 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,26 @@ #!/bin/bash set -e # if parameters that start with '-' were passed to the script via the CMD directive then concat # them to the string 'mongod' if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi # if the last conditional statement was triggered or if we're running without any parameters # (ie, the parameter 'mongod' was passed in from +++the docker executor) AND we're running as # root then do stuff. NOTE: if we're inside of recursion this won't fire if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then # give the mongodb user ownership of its working dirs chown -R mongodb /data/configdb /data/db # recurse into this script but run as the user mongodb (bash_source is a shortcut to # the name of the script we're currently in) # gosu is an off-brand su command. ex: gosu <username> <executable> <arguments> exec gosu mongodb "$BASH_SOURCE" "$@" fi # this is the final step where we preface the $@ string with numactl which handles memory # usage. This will execute every time unless the parameters sent are something other than mongod or an argument. if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then -
consolewitch created this gist
Mar 25, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/bin/bash set -e # if parameters that start with '-' were passed to the script via the CMD directive then concat them to the string 'mongod' if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi # if the last conditional statement was triggered or if we're running without any parameters (ie, the parameter 'mongod' was passed in from +++the docker executor) AND we're running as root then do stuff. NOTE: if we're inside of recursion this won't fire if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then #give the mongodb user ownership of its working dirs chown -R mongodb /data/configdb /data/db #recurse into this script but run as the user mongodb (bash_source is a shortcut to the name of the script we're currently in) #gosu is an off-brand su command. ex: gosu <username> <executable> <arguments> exec gosu mongodb "$BASH_SOURCE" "$@" fi #this is the final step where we preface the $@ string with numactl which handles memory usage. This will execute every time unless the +++parameters sent are something other than mongod or an argument. if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi fi #here we actually fire off whatever is in the $@ string. exec "$@"