Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrezigned <rezigned@gmail.com>2013-05-09 09:37:56 +0400
committerrezigned <rezigned@gmail.com>2013-05-09 09:37:56 +0400
commit76d958ebe79d6ee6fa3229f02e91ba21bc65ecb6 (patch)
tree639b36f8f8cc8b046b435cd7ccd3f4c8b6c50d2d /lib/support
parent25d5c1f63714d28a331095cf5b03fa577d3734d1 (diff)
Update init.d script
The original init.d script uses a fixed username (e.g. git). Which is not flexible when we using other user. So, I've updated it to use $APP_USER variable instead and wrap it in a function to reduce repetitive codes.
Diffstat (limited to 'lib/support')
-rw-r--r--lib/support/init.d/gitlab15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab
index 6e836472205..9c922f85b6a 100644
--- a/lib/support/init.d/gitlab
+++ b/lib/support/init.d/gitlab
@@ -16,6 +16,7 @@
APP_ROOT="/home/git/gitlab"
+APP_USER="git"
DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production"
PID_PATH="$APP_ROOT/tmp/pids"
WEB_SERVER_PID="$PID_PATH/puma.pid"
@@ -36,6 +37,10 @@ check_pid(){
fi
}
+execute() {
+ sudo -u $APP_USER -H bash -l -c "$1"
+}
+
start() {
cd $APP_ROOT
check_pid
@@ -45,8 +50,8 @@ start() {
exit 1
else
if [ `whoami` = root ]; then
- sudo -u git -H bash -l -c "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 "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
+ execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
echo "$DESC started"
fi
fi
@@ -58,7 +63,7 @@ stop() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
## Program is running, stop it.
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
echo "$DESC stopped"
else
@@ -74,9 +79,9 @@ restart() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "Restarting $DESC..."
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
- 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
echo "$DESC restarted."
else