Commit 4353babe61a57be128bd967731e7c536c9a55ba3
Exists in
master
and in
4 other branches
Merge pull request #3893 from rezigned/feature/update-init.d
Update init.d script
Showing
1 changed file
with
10 additions
and
5 deletions
Show diff stats
lib/support/init.d/gitlab
| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | APP_ROOT="/home/git/gitlab" |
| 19 | +APP_USER="git" | |
| 19 | 20 | DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production" |
| 20 | 21 | PID_PATH="$APP_ROOT/tmp/pids" |
| 21 | 22 | WEB_SERVER_PID="$PID_PATH/puma.pid" |
| ... | ... | @@ -36,6 +37,10 @@ check_pid(){ |
| 36 | 37 | fi |
| 37 | 38 | } |
| 38 | 39 | |
| 40 | +execute() { | |
| 41 | + sudo -u $APP_USER -H bash -l -c "$1" | |
| 42 | +} | |
| 43 | + | |
| 39 | 44 | start() { |
| 40 | 45 | cd $APP_ROOT |
| 41 | 46 | check_pid |
| ... | ... | @@ -45,8 +50,8 @@ start() { |
| 45 | 50 | exit 1 |
| 46 | 51 | else |
| 47 | 52 | if [ `whoami` = root ]; then |
| 48 | - sudo -u git -H bash -l -c "RAILS_ENV=production bundle exec puma $DAEMON_OPTS" | |
| 49 | - sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" | |
| 53 | + execute "RAILS_ENV=production bundle exec puma $DAEMON_OPTS" | |
| 54 | + execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" | |
| 50 | 55 | echo "$DESC started" |
| 51 | 56 | fi |
| 52 | 57 | fi |
| ... | ... | @@ -58,7 +63,7 @@ stop() { |
| 58 | 63 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then |
| 59 | 64 | ## Program is running, stop it. |
| 60 | 65 | kill -QUIT `cat $WEB_SERVER_PID` |
| 61 | - sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | |
| 66 | + execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | |
| 62 | 67 | rm "$WEB_SERVER_PID" >> /dev/null |
| 63 | 68 | echo "$DESC stopped" |
| 64 | 69 | else |
| ... | ... | @@ -74,9 +79,9 @@ restart() { |
| 74 | 79 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then |
| 75 | 80 | echo "Restarting $DESC..." |
| 76 | 81 | kill -USR2 `cat $WEB_SERVER_PID` |
| 77 | - sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | |
| 82 | + execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | |
| 78 | 83 | if [ `whoami` = root ]; then |
| 79 | - sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" | |
| 84 | + execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" | |
| 80 | 85 | fi |
| 81 | 86 | echo "$DESC restarted." |
| 82 | 87 | else | ... | ... |