From 0ea8107191ea1a3bc8b4b57623c981c06f38092e Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Fri, 1 Jun 2018 14:59:25 +0100 Subject: [PATCH] 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`. --- run.sh | 10 ++++------ run_reports.sh | 4 ++-- run_tool_shed.sh | 4 ++-- scripts/common_startup_functions.sh | 24 ++++++++++++++---------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/run.sh b/run.sh index ea1a8e98052..da88ac43f70 100755 --- a/run.sh +++ b/run.sh @@ -78,8 +78,9 @@ if [ "$run_server" = "python" -a -n "$GALAXY_RUN_ALL" ]; then exit 1 fi for server in $servers; do + echo "Executing: python $server_args --server-name=\"$server\" --pid-file=\"$server.pid\" --log-file=\"$server.log\"" + python $server_args --server-name="$server" --pid-file="$server.pid" --log-file="$server.log" if [ -n "$wait_arg_set" -a -n "$daemon_or_restart_arg_set" ]; then - python ./scripts/paster.py serve "$GALAXY_CONFIG_FILE" --server-name="$server" --pid-file="$server.pid" --log-file="$server.log" $paster_args while true; do sleep 1 printf "." @@ -95,13 +96,10 @@ if [ "$run_server" = "python" -a -n "$GALAXY_RUN_ALL" ]; then [ -n "$latest_pid" ] && [ "$latest_pid" -eq "$current_pid_in_file" ] && break done echo - else - echo "Handling $server with log file $server.log..." - python ./scripts/paster.py serve "$GALAXY_CONFIG_FILE" --server-name="$server" --pid-file="$server.pid" --log-file="$server.log" $paster_args fi done else - echo "executing: $run_server $server_args" + echo "Executing: $run_server $server_args $pid_log_paster_args" # args are properly quoted so use eval - eval $run_server $server_args + eval $run_server $server_args $pid_log_paster_args fi diff --git a/run_reports.sh b/run_reports.sh index 9692904d41b..a8ab6b70b84 100755 --- a/run_reports.sh +++ b/run_reports.sh @@ -48,5 +48,5 @@ if [ -n "$GALAXY_REPORTS_CONFIG_DIR" ]; then fi find_server ${GALAXY_REPORTS_CONFIG:-none} reports -echo "executing: $run_server $server_args" -eval $run_server $server_args +echo "Executing: $run_server $server_args $pid_log_paster_args" +eval $run_server $server_args $pid_log_paster_args diff --git a/run_tool_shed.sh b/run_tool_shed.sh index e5bd35749e8..171dc38ec58 100755 --- a/run_tool_shed.sh +++ b/run_tool_shed.sh @@ -37,5 +37,5 @@ if [ -z "$TOOL_SHED_CONFIG_FILE" ]; then fi find_server ${TOOL_SHED_CONFIG_FILE:-none} tool_shed -echo "executing: $run_server $server_args" -eval $run_server $server_args +echo "Executing: $run_server $server_args $pid_log_paster_args" +eval $run_server $server_args $pid_log_paster_args diff --git a/scripts/common_startup_functions.sh b/scripts/common_startup_functions.sh index 5d0fa87f8b1..b1e9d18852a 100644 --- a/scripts/common_startup_functions.sh +++ b/scripts/common_startup_functions.sh @@ -22,30 +22,33 @@ parse_common_args() { --stop-daemon|stop) common_startup_args="$common_startup_args --stop-daemon" paster_args="$paster_args --stop-daemon" - uwsgi_args="$uwsgi_args --stop $PID_FILE" + pid_log_paster_args="--pid-file \"$PID_FILE\"" + uwsgi_args="$uwsgi_args --stop \"$PID_FILE\"" stop_daemon_arg_set=1 shift ;; --restart|restart) - if [ "$1" = "--restart" ] - then - paster_args="$paster_args restart" - else - paster_args="$paster_args $1" - fi - uwsgi_args="$uwsgi_args --reload $PID_FILE" + 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" + 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 @@ -115,8 +118,9 @@ find_server() { 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 --pid-file $PID_FILE --log-file $LOG_FILE $paster_args" + server_args="./scripts/paster.py serve $server_config $paster_args" fi }