mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Fix Puma start
+start+ did not read the environment variables. However, e.g. +phased-restart+ did. Also +start+ was implemented quite differently from other actions. Now +start+ is implemented like the other actions, it respects environment variables and there's a lot less code duplication going on.
This commit is contained in:
parent
4ad972c6f0
commit
cfa301bb7e
1 changed files with 26 additions and 56 deletions
|
@ -39,17 +39,7 @@ do_start() {
|
||||||
log_daemon_msg "=> Running the jungle..."
|
log_daemon_msg "=> Running the jungle..."
|
||||||
for i in $JUNGLE; do
|
for i in $JUNGLE; do
|
||||||
dir=`echo $i | cut -d , -f 1`
|
dir=`echo $i | cut -d , -f 1`
|
||||||
user=`echo $i | cut -d , -f 2`
|
do_start_one $dir
|
||||||
config_file=`echo $i | cut -d , -f 3`
|
|
||||||
if [ "$config_file" = "" ]; then
|
|
||||||
config_file="$dir/config/puma.rb"
|
|
||||||
fi
|
|
||||||
log_file=`echo $i | cut -d , -f 4`
|
|
||||||
if [ "$log_file" = "" ]; then
|
|
||||||
log_file="$dir/log/puma.log"
|
|
||||||
fi
|
|
||||||
environment=`echo $i | cut -d , -f 5`
|
|
||||||
do_start_one $dir $user $config_file $log_file $environment
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,28 +49,41 @@ do_start_one() {
|
||||||
PID=`cat $PIDFILE`
|
PID=`cat $PIDFILE`
|
||||||
# If the puma isn't running, run it, otherwise restart it.
|
# If the puma isn't running, run it, otherwise restart it.
|
||||||
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
||||||
do_start_one_do $1 $2 $3 $4 $5
|
do_start_one_do $1
|
||||||
else
|
else
|
||||||
do_restart_one $1
|
do_restart_one $1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
do_start_one_do $1 $2 $3 $4 $5
|
do_start_one_do $1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_start_one_do() {
|
do_start_one_do() {
|
||||||
log_daemon_msg "--> Woke up puma $1"
|
i=`grep $1 $CONFIG`
|
||||||
log_daemon_msg "user $2"
|
dir=`echo $i | cut -d , -f 1`
|
||||||
log_daemon_msg "log to $4"
|
user=`echo $i | cut -d , -f 2`
|
||||||
|
config_file=`echo $i | cut -d , -f 3`
|
||||||
|
if [ "$config_file" = "" ]; then
|
||||||
|
config_file="$dir/config/puma.rb"
|
||||||
|
fi
|
||||||
|
log_file=`echo $i | cut -d , -f 4`
|
||||||
|
if [ "$log_file" = "" ]; then
|
||||||
|
log_file="$dir/log/puma.log"
|
||||||
|
fi
|
||||||
|
environment=`echo $i | cut -d , -f 5`
|
||||||
|
|
||||||
if [ ! -z "$5" ]; then
|
log_daemon_msg "--> Woke up puma $dir"
|
||||||
for e in $(echo "$5" | tr ';' '\n'); do
|
log_daemon_msg "user $user"
|
||||||
|
log_daemon_msg "log to $log_file"
|
||||||
|
|
||||||
|
if [ ! -z "$environment" ]; then
|
||||||
|
for e in $(echo "$environment" | tr ';' '\n'); do
|
||||||
log_daemon_msg "environment $e"
|
log_daemon_msg "environment $e"
|
||||||
v=${e%%\=*} ; eval "$e" ; export $v
|
v=${e%%\=*} ; eval "$e" ; export $v
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA -- $1 $3 $4
|
start-stop-daemon --verbose --start --chdir $dir --chuid $user --background --exec $RUNPUMA -- $dir $config_file $log_file
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -135,8 +138,6 @@ do_restart() {
|
||||||
#
|
#
|
||||||
do_restart_one() {
|
do_restart_one() {
|
||||||
PIDFILE=$1/tmp/puma/pid
|
PIDFILE=$1/tmp/puma/pid
|
||||||
i=`grep $1 $CONFIG`
|
|
||||||
dir=`echo $i | cut -d , -f 1`
|
|
||||||
|
|
||||||
if [ -e $PIDFILE ]; then
|
if [ -e $PIDFILE ]; then
|
||||||
log_daemon_msg "--> About to restart puma $1"
|
log_daemon_msg "--> About to restart puma $1"
|
||||||
|
@ -144,17 +145,7 @@ do_restart_one() {
|
||||||
# TODO Check if process exist
|
# TODO Check if process exist
|
||||||
else
|
else
|
||||||
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
||||||
user=`echo $i | cut -d , -f 2`
|
do_start_one $1
|
||||||
config_file=`echo $i | cut -d , -f 3`
|
|
||||||
if [ "$config_file" = "" ]; then
|
|
||||||
config_file="$dir/config/puma.rb"
|
|
||||||
fi
|
|
||||||
log_file=`echo $i | cut -d , -f 4`
|
|
||||||
if [ "$log_file" = "" ]; then
|
|
||||||
log_file="$dir/log/puma.log"
|
|
||||||
fi
|
|
||||||
environment=`echo $i | cut -d , -f 5`
|
|
||||||
do_start_one $dir $user $config_file $log_file $environment
|
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -174,8 +165,6 @@ do_phased_restart() {
|
||||||
#
|
#
|
||||||
do_phased_restart_one() {
|
do_phased_restart_one() {
|
||||||
PIDFILE=$1/tmp/puma/pid
|
PIDFILE=$1/tmp/puma/pid
|
||||||
i=`grep $1 $CONFIG`
|
|
||||||
dir=`echo $i | cut -d , -f 1`
|
|
||||||
|
|
||||||
if [ -e $PIDFILE ]; then
|
if [ -e $PIDFILE ]; then
|
||||||
log_daemon_msg "--> About to restart puma $1"
|
log_daemon_msg "--> About to restart puma $1"
|
||||||
|
@ -183,17 +172,7 @@ do_phased_restart_one() {
|
||||||
# TODO Check if process exist
|
# TODO Check if process exist
|
||||||
else
|
else
|
||||||
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
||||||
user=`echo $i | cut -d , -f 2`
|
do_start_one $1
|
||||||
config_file=`echo $i | cut -d , -f 3`
|
|
||||||
if [ "$config_file" = "" ]; then
|
|
||||||
config_file="$dir/config/puma.rb"
|
|
||||||
fi
|
|
||||||
log_file=`echo $i | cut -d , -f 4`
|
|
||||||
if [ "$log_file" = "" ]; then
|
|
||||||
log_file="$dir/log/puma.log"
|
|
||||||
fi
|
|
||||||
environment=`echo $i | cut -d , -f 5`
|
|
||||||
do_start_one $dir $user $config_file $log_file $environment
|
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -339,16 +318,7 @@ case "$1" in
|
||||||
else
|
else
|
||||||
i=`grep $2 $CONFIG`
|
i=`grep $2 $CONFIG`
|
||||||
dir=`echo $i | cut -d , -f 1`
|
dir=`echo $i | cut -d , -f 1`
|
||||||
user=`echo $i | cut -d , -f 2`
|
do_start_one $dir
|
||||||
config_file=`echo $i | cut -d , -f 3`
|
|
||||||
if [ "$config_file" = "" ]; then
|
|
||||||
config_file="$dir/config/puma.rb"
|
|
||||||
fi
|
|
||||||
log_file=`echo $i | cut -d , -f 4`
|
|
||||||
if [ "$log_file" = "" ]; then
|
|
||||||
log_file="$dir/log/puma.log"
|
|
||||||
fi
|
|
||||||
do_start_one $dir $user $config_file $log_file
|
|
||||||
fi
|
fi
|
||||||
case "$?" in
|
case "$?" in
|
||||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||||
|
|
Loading…
Reference in a new issue