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,6 +16,7 @@ | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | APP_ROOT="/home/git/gitlab" | 18 | APP_ROOT="/home/git/gitlab" |
| 19 | +APP_USER="git" | ||
| 19 | DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production" | 20 | DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production" |
| 20 | PID_PATH="$APP_ROOT/tmp/pids" | 21 | PID_PATH="$APP_ROOT/tmp/pids" |
| 21 | WEB_SERVER_PID="$PID_PATH/puma.pid" | 22 | WEB_SERVER_PID="$PID_PATH/puma.pid" |
| @@ -36,6 +37,10 @@ check_pid(){ | @@ -36,6 +37,10 @@ check_pid(){ | ||
| 36 | fi | 37 | fi |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 40 | +execute() { | ||
| 41 | + sudo -u $APP_USER -H bash -l -c "$1" | ||
| 42 | +} | ||
| 43 | + | ||
| 39 | start() { | 44 | start() { |
| 40 | cd $APP_ROOT | 45 | cd $APP_ROOT |
| 41 | check_pid | 46 | check_pid |
| @@ -45,8 +50,8 @@ start() { | @@ -45,8 +50,8 @@ start() { | ||
| 45 | exit 1 | 50 | exit 1 |
| 46 | else | 51 | else |
| 47 | if [ `whoami` = root ]; then | 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 | echo "$DESC started" | 55 | echo "$DESC started" |
| 51 | fi | 56 | fi |
| 52 | fi | 57 | fi |
| @@ -58,7 +63,7 @@ stop() { | @@ -58,7 +63,7 @@ stop() { | ||
| 58 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | 63 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then |
| 59 | ## Program is running, stop it. | 64 | ## Program is running, stop it. |
| 60 | kill -QUIT `cat $WEB_SERVER_PID` | 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 | rm "$WEB_SERVER_PID" >> /dev/null | 67 | rm "$WEB_SERVER_PID" >> /dev/null |
| 63 | echo "$DESC stopped" | 68 | echo "$DESC stopped" |
| 64 | else | 69 | else |
| @@ -74,9 +79,9 @@ restart() { | @@ -74,9 +79,9 @@ restart() { | ||
| 74 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | 79 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then |
| 75 | echo "Restarting $DESC..." | 80 | echo "Restarting $DESC..." |
| 76 | kill -USR2 `cat $WEB_SERVER_PID` | 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 | if [ `whoami` = root ]; then | 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 | fi | 85 | fi |
| 81 | echo "$DESC restarted." | 86 | echo "$DESC restarted." |
| 82 | else | 87 | else |