96 lines
2.7 KiB
Bash
96 lines
2.7 KiB
Bash
#!/bin/bash -e
|
|
|
|
showUsage()
|
|
{
|
|
cat <<EOF
|
|
Usage: $0 [OPTION] PATH
|
|
|
|
This command starts supervisord with a provided configuration and set of
|
|
services in foreground mode. When the configuration changes, supervisord and all
|
|
services need to be restarted.
|
|
|
|
To do more efficient (but stateful) upgrades, use
|
|
\`nixproc-supervisord-switch'.
|
|
|
|
Options:
|
|
--state-dir Changes the directory in which the state of the
|
|
processes are stored
|
|
--runtime-dir Changes the directory in which the PID files are stored
|
|
--log-dir Changes the directory in which the log files are stored
|
|
--tmp-dir Changes the directory in which temp files are stored
|
|
--force-disable-user-change
|
|
Forces to not create users, groups or change user
|
|
permissions
|
|
-h, --help Shows the usage of this command
|
|
|
|
Environment:
|
|
NIXPROC_STATE_DIR Changes the directory in which the state of the
|
|
processes is stored
|
|
NIXPROC_RUNTIME_DIR Changes the directory in which the PID files are stored
|
|
NIXPROC_LOG_DIR Changes the directory in which log files are stored
|
|
NIXPROC_TMP_DIR Changes the directory in which temp files are stored
|
|
NIXPROC_FORCE_DISABLE_USER_CHANGE
|
|
Forces to not create users, groups or change user
|
|
permissions
|
|
EOF
|
|
}
|
|
|
|
# Parse valid argument options
|
|
|
|
PARAMS=`@getopt@ -n $0 -o h -l state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,help -- "$@"`
|
|
|
|
if [ $? != 0 ]
|
|
then
|
|
showUsage
|
|
exit 1
|
|
fi
|
|
|
|
# Evaluate valid options
|
|
|
|
eval set -- "$PARAMS"
|
|
|
|
while [ "$1" != "--" ]
|
|
do
|
|
case "$1" in
|
|
--state-dir)
|
|
stateDirArg="--state-dir $2"
|
|
;;
|
|
--runtime-dir)
|
|
runtimeDirArg="--runtime-dir $2"
|
|
;;
|
|
--log-dir)
|
|
logDirArg="--log-dir $2"
|
|
;;
|
|
--tmp-dir)
|
|
tmpDirArg="--tmp-dir $2"
|
|
;;
|
|
--force-disable-user-change)
|
|
forceDisableUserChangeArg="--force-disable-user-change"
|
|
;;
|
|
-h|--help)
|
|
showUsage
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
shift
|
|
done
|
|
|
|
shift
|
|
|
|
path="$1"
|
|
|
|
# Build the environment with supervisord config files
|
|
profilePath=$(nixproc-build --process-manager supervisord $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $showTraceArg --no-out-link "$path")
|
|
|
|
# Create groups and users
|
|
dysnomia-addgroups "$profilePath"
|
|
dysnomia-addusers "$profilePath"
|
|
|
|
# Start supervisord in foreground mode
|
|
supervisord -n -c "$profilePath/supervisord.conf"
|
|
|
|
# Discard groups and users
|
|
dysnomia-delusers "$profilePath"
|
|
dysnomia-delgroups "$profilePath"
|