Commit 4353babe authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #3893 from rezigned/feature/update-init.d

Update init.d script
parents 25d5c1f6 76d958eb
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
APP_ROOT="/home/git/gitlab" APP_ROOT="/home/git/gitlab"
APP_USER="git"
DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production" DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production"
PID_PATH="$APP_ROOT/tmp/pids" PID_PATH="$APP_ROOT/tmp/pids"
WEB_SERVER_PID="$PID_PATH/puma.pid" WEB_SERVER_PID="$PID_PATH/puma.pid"
...@@ -36,6 +37,10 @@ check_pid(){ ...@@ -36,6 +37,10 @@ check_pid(){
fi fi
} }
execute() {
sudo -u $APP_USER -H bash -l -c "$1"
}
start() { start() {
cd $APP_ROOT cd $APP_ROOT
check_pid check_pid
...@@ -45,8 +50,8 @@ start() { ...@@ -45,8 +50,8 @@ start() {
exit 1 exit 1
else else
if [ `whoami` = root ]; then if [ `whoami` = root ]; then
sudo -u git -H bash -l -c "RAILS_ENV=production bundle exec puma $DAEMON_OPTS" execute "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
echo "$DESC started" echo "$DESC started"
fi fi
fi fi
...@@ -58,7 +63,7 @@ stop() { ...@@ -58,7 +63,7 @@ stop() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
## Program is running, stop it. ## Program is running, stop it.
kill -QUIT `cat $WEB_SERVER_PID` kill -QUIT `cat $WEB_SERVER_PID`
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
rm "$WEB_SERVER_PID" >> /dev/null rm "$WEB_SERVER_PID" >> /dev/null
echo "$DESC stopped" echo "$DESC stopped"
else else
...@@ -74,9 +79,9 @@ restart() { ...@@ -74,9 +79,9 @@ restart() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "Restarting $DESC..." echo "Restarting $DESC..."
kill -USR2 `cat $WEB_SERVER_PID` kill -USR2 `cat $WEB_SERVER_PID`
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
if [ `whoami` = root ]; then if [ `whoami` = root ]; then
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
fi fi
echo "$DESC restarted." echo "$DESC restarted."
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment