Skip to content

Commit

Permalink
Merge pull request #610 from kwilczynski/master
Browse files Browse the repository at this point in the history
Add the ability to pass environment variables to the init script (for Ju...
  • Loading branch information
evanphx committed Nov 27, 2014
2 parents bdb3478 + 266540c commit d690763
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tools/jungle/init.d/puma
Expand Up @@ -47,7 +47,8 @@ do_start() {
if [ "$log_file" = "" ]; then
log_file="$dir/log/puma.log"
fi
do_start_one $dir $user $config_file $log_file
environment=`echo $i | cut -d , -f 5`
do_start_one $dir $user $config_file $log_file $environment
done
}

Expand All @@ -57,19 +58,27 @@ 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
do_start_one_do $1 $2 $3 $4 $5
else
do_restart_one $1
fi
else
do_start_one_do $1 $2 $3 $4
do_start_one_do $1 $2 $3 $4 $5
fi
}

do_start_one_do() {
log_daemon_msg "--> Woke up puma $1"
log_daemon_msg "user $2"
log_daemon_msg "log to $4"

if [ ! -z "$5" ]; then
for e in $(echo "$5" | 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
}

Expand Down Expand Up @@ -140,7 +149,8 @@ do_restart_one() {
if [ "$log_file" = "" ]; then
log_file="$dir/log/puma.log"
fi
do_start_one $dir $user $config_file $log_file
environment=`echo $i | cut -d , -f 5`
do_start_one $dir $user $config_file $log_file $environment
fi
return 0
}
Expand Down Expand Up @@ -209,6 +219,11 @@ do_add() {
str="$str,$4"
fi

# Environment variables
if [ "$5" != "" ]; then
str="$str,$5"
fi

# Add it to the jungle
echo $str >> $CONFIG
log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though."
Expand Down

0 comments on commit d690763

Please sign in to comment.