Files
galaxy/scripts/common_startup_functions.sh
T
Nicola Soranzo 0ea8107191 Use separate pid_log_paster_args variable
to store --pid-file and --log-file options of `./scripts/paster.py` .

https://github.com/galaxyproject/galaxy/pull/6239 fixed 3 bugs:

- `GALAXY_RUN_ALL=1 ./run.sh` was reusing the same pid and log files for
  all Galaxy processes;
- `./run.sh restart` was always using `paster.pid` and `paster.log` instead
  of the configured files
- `./run.sh status` was always using `paster.pid`

but also introduced a regression, i.e. the plain `./run.sh` started
writing to the log file instead of the standard output (console).

This fixes the regression by using a separate variable for these options
instead of conflating them in `paster_args` or `server_args`.
2018-06-02 01:09:10 +01:00

127 lines
4.3 KiB
Bash

#!/bin/sh
parse_common_args() {
INITIALIZE_TOOL_DEPENDENCIES=1
# Pop args meant for common_startup.sh
while :
do
case "$1" in
--skip-eggs|--skip-wheels|--skip-samples|--dev-wheels|--no-create-venv|--no-replace-pip|--replace-pip|--skip-client-build)
common_startup_args="$common_startup_args $1"
shift
;;
--skip-tool-dependency-initialization)
INITIALIZE_TOOL_DEPENDENCIES=0
shift
;;
--skip-venv)
skip_venv=1
common_startup_args="$common_startup_args $1"
shift
;;
--stop-daemon|stop)
common_startup_args="$common_startup_args --stop-daemon"
paster_args="$paster_args --stop-daemon"
pid_log_paster_args="--pid-file \"$PID_FILE\""
uwsgi_args="$uwsgi_args --stop \"$PID_FILE\""
stop_daemon_arg_set=1
shift
;;
--restart|restart)
paster_args="$paster_args restart"
pid_log_paster_args="--pid-file \"$PID_FILE\" --log-file \"$LOG_FILE\""
uwsgi_args="$uwsgi_args --reload \"$PID_FILE\""
restart_arg_set=1
daemon_or_restart_arg_set=1
shift
;;
--daemon|start)
paster_args="$paster_args --daemon"
pid_log_paster_args="--pid-file \"$PID_FILE\" --log-file \"$LOG_FILE\""
# --daemonize2 waits until after the application has loaded
# to daemonize, thus it stops if any errors are found
uwsgi_args="--master --daemonize2 \"$LOG_FILE\" --pidfile2 \"$PID_FILE\" $uwsgi_args"
daemon_or_restart_arg_set=1
shift
;;
--status|status)
paster_args="$paster_args $1"
pid_log_paster_args="--pid-file \"$PID_FILE\""
shift
;;
--wait)
wait_arg_set=1
shift
;;
"")
break
;;
*)
paster_args="$paster_args $1"
uwsgi_args="$uwsgi_args $1"
shift
;;
esac
done
}
run_common_start_up() {
./scripts/common_startup.sh $common_startup_args || exit 1
}
setup_python() {
# If there is a .venv/ directory, assume it contains a virtualenv that we
# should run this instance in.
GALAXY_VIRTUAL_ENV="${GALAXY_VIRTUAL_ENV:-.venv}"
if [ -d "$GALAXY_VIRTUAL_ENV" -a -z "$skip_venv" ];
then
[ -n "$PYTHONPATH" ] && { echo 'Unsetting $PYTHONPATH'; unset PYTHONPATH; }
echo "Activating virtualenv at $GALAXY_VIRTUAL_ENV"
. "$GALAXY_VIRTUAL_ENV/bin/activate"
fi
# If you are using --skip-venv we assume you know what you are doing but warn
# in case you don't.
[ -n "$PYTHONPATH" ] && echo 'WARNING: $PYTHONPATH is set, this can cause problems importing Galaxy dependencies'
python ./scripts/check_python.py || exit 1
}
find_server() {
server_config="$1"
server_app="$2"
arg_getter_args=
default_webserver="paste"
case "$server_config" in
*.y*ml|''|none)
default_webserver="uwsgi" # paste incapable of this
;;
esac
APP_WEBSERVER=${APP_WEBSERVER:-$default_webserver}
if [ "$APP_WEBSERVER" = "uwsgi" ];
then
# Look for uwsgi
if [ -z "$skip_venv" -a -x $GALAXY_VIRTUAL_ENV/bin/uwsgi ]; then
UWSGI=$GALAXY_VIRTUAL_ENV/bin/uwsgi
elif command -v uwsgi >/dev/null 2>&1; then
UWSGI=uwsgi
else
echo 'ERROR: Could not find uwsgi executable'
exit 1
fi
[ "$server_config" != "none" ] && arg_getter_args="-c $server_config"
[ -n "$server_app" ] && arg_getter_args="--app $server_app"
run_server="$UWSGI"
server_args=
if [ -z "$stop_daemon_arg_set" -a -z "$restart_arg_set" ]; then
server_args="$(python ./scripts/get_uwsgi_args.py $arg_getter_args)"
fi
server_args="$server_args $uwsgi_args"
pid_log_paster_args=""
else
run_server="python"
server_args="./scripts/paster.py serve $server_config $paster_args"
fi
}