Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Puma init.d start #1061

Merged
merged 1 commit into from
Sep 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
82 changes: 26 additions & 56 deletions tools/jungle/init.d/puma
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,7 @@ do_start() {
log_daemon_msg "=> Running the jungle..."
for i in $JUNGLE; do
dir=`echo $i | cut -d , -f 1`
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`
do_start_one $dir $user $config_file $log_file $environment
do_start_one $dir
done
}

Expand All @@ -59,28 +49,41 @@ do_start_one() {
PID=`cat $PIDFILE`
# If the puma isn't running, run it, otherwise restart it.
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
do_restart_one $1
fi
else
do_start_one_do $1 $2 $3 $4 $5
do_start_one_do $1
fi
}

do_start_one_do() {
log_daemon_msg "--> Woke up puma $1"
log_daemon_msg "user $2"
log_daemon_msg "log to $4"
i=`grep $1 $CONFIG`
dir=`echo $i | cut -d , -f 1`
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`

log_daemon_msg "--> Woke up puma $dir"
log_daemon_msg "user $user"
log_daemon_msg "log to $log_file"

if [ ! -z "$5" ]; then
for e in $(echo "$5" | tr ';' '\n'); do
if [ ! -z "$environment" ]; then
for e in $(echo "$environment" | tr ';' '\n'); do
log_daemon_msg "environment $e"
v=${e%%\=*} ; eval "$e" ; export $v
done
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
}

#
Expand Down Expand Up @@ -135,26 +138,14 @@ do_restart() {
#
do_restart_one() {
PIDFILE=$1/tmp/puma/pid
i=`grep $1 $CONFIG`
dir=`echo $i | cut -d , -f 1`

if [ -e $PIDFILE ]; then
log_daemon_msg "--> About to restart puma $1"
kill -s USR2 `cat $PIDFILE`
# TODO Check if process exist
else
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
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`
do_start_one $dir $user $config_file $log_file $environment
do_start_one $1
fi
return 0
}
Expand All @@ -174,26 +165,14 @@ do_phased_restart() {
#
do_phased_restart_one() {
PIDFILE=$1/tmp/puma/pid
i=`grep $1 $CONFIG`
dir=`echo $i | cut -d , -f 1`

if [ -e $PIDFILE ]; then
log_daemon_msg "--> About to restart puma $1"
kill -s USR1 `cat $PIDFILE`
# TODO Check if process exist
else
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
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`
do_start_one $dir $user $config_file $log_file $environment
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
do_start_one $1
fi
return 0
}
Expand Down Expand Up @@ -339,16 +318,7 @@ case "$1" in
else
i=`grep $2 $CONFIG`
dir=`echo $i | cut -d , -f 1`
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
do_start_one $dir $user $config_file $log_file
do_start_one $dir
fi
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
Expand Down