]> git.pld-linux.org Git - packages/gitlab-ce.git/commitdiff
add gitlab-sidekiq, gitlab-unicorn initscripts
authorElan Ruusamäe <glen@delfi.ee>
Fri, 13 May 2016 18:31:55 +0000 (21:31 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 15 May 2016 07:31:01 +0000 (10:31 +0300)
from https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/init/sysvinit/centos@7ff25bb

gitlab-ce.spec
gitlab-sidekiq.init [new file with mode: 0755]
gitlab-unicorn.init [new file with mode: 0755]

index 4ff17d3c7346d61ba037534be1e6cf9a3565fed0..cdecc8a555b28ea053e77fcb57e47fc2ff35663b 100644 (file)
@@ -17,7 +17,7 @@
 Summary:       A Web interface to create projects and repositories, manage access and do code reviews
 Name:          gitlab-ce
 Version:       8.7.5
-Release:       0.12
+Release:       0.13
 License:       MIT
 Group:         Applications/WWW
 # md5 deliberately omitted until this package is useful
@@ -26,10 +26,12 @@ Patch0:             https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3774.patch
 URL:           https://www.gitlab.com/gitlab-ce/
 Source1:       gitlab.target
 Source2:       gitlab-sidekiq.service
-Source3:       gitlab-unicorn.service
-Source4:       gitlab.logrotate
-Source5:       gitlab.tmpfiles.d
-Source6:       gitlab-apache-conf
+Source3:       gitlab-sidekiq.init
+Source4:       gitlab-unicorn.service
+Source5:       gitlab-unicorn.init
+Source6:       gitlab.logrotate
+Source7:       gitlab.tmpfiles.d
+Source8:       gitlab-apache-conf
 BuildRequires: cmake
 BuildRequires: gmp-devel
 BuildRequires: libgit2-devel
@@ -150,15 +152,17 @@ for f in gitlab.yml unicorn.rb database.yml; do
 done
 
 install -d $RPM_BUILD_ROOT{%{systemdunitdir},%{systemdtmpfilesdir}} \
-       $RPM_BUILD_ROOT/etc/{logrotate.d,httpd/webapps.d}
+       $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,httpd/webapps.d}
 
-# Install systemd service files
-cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-sidekiq.service
-cp -p %{SOURCE3} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
-cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
-cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
-cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
+install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-sidekiq
+cp -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab-unicorn.service
+install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/gitlab-unicorn
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/gitlab.target
+cp -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/gitlab.conf
+cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
+cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
 
 %clean
 rm -rf "$RPM_BUILD_ROOT"
@@ -202,6 +206,8 @@ fi
 %config(noreplace) %{_sysconfdir}/gitlab/unicorn.rb
 %config(noreplace) %{_sysconfdir}/httpd/webapps.d/gitlab.conf
 /etc/logrotate.d/gitlab.logrotate
+%attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
+%attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
 %{systemdunitdir}/gitlab-sidekiq.service
 %{systemdunitdir}/gitlab-unicorn.service
 %{systemdunitdir}/gitlab.target
diff --git a/gitlab-sidekiq.init b/gitlab-sidekiq.init
new file mode 100755 (executable)
index 0000000..9b06a4c
--- /dev/null
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# gitlab-sidekiq GitLab Sidekiq Worker
+#
+# chkconfig:   345 82 18
+# description: Runs GitLab Sidekiq Worker
+# processname: sidekiq
+
+# Related (kudos @4sak3n0ne):
+# https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
+# https://gist.github.com/3062860
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "GitLab Sidekiq"
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+### Environment variables
+RAILS_ENV="production"
+
+# The username and path to the gitlab source
+USER=git
+APP_PATH=/var/lib/gitlab
+
+# The PID and LOCK files used by unicorn and sidekiq
+pidfile=$APP_PATH/tmp/pids/sidekiq.pid
+lockfile=/var/lock/subsys/gitlab-sidekiq
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/gitlab-sidekiq ] && . /etc/sysconfig/gitlab-sidekiq
+
+start() {
+       # Check if the service is already running?
+       if [ -f $lockfile ]; then
+               msg_already_running "GitLab Sidekiq"
+               return
+       fi
+
+       msg_starting "GitLab Sidekiq"
+       daemon --pidfile $pidfile --user $USER --chdir "$APP_PATH" \
+               bundle exec \
+               "sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P pids/sidekiq.pid -d -L log/sidekiq.log >> log/sidekiq.log 2>&1"
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch $lockfile
+}
+
+stop() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "GitLab Sidekiq"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "GitLab Sidekiq"
+       killproc --pidfile $pidfile sidekiq
+       rm -f $lockfile
+}
+
+reload() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "GitLab Sidekiq"
+               RETVAL=7
+               return
+       fi
+
+       msg_reloading "GitLab Sidekiq"
+       killproc <procname> -HUP
+       killproc --pidfile $pidfile <procname> -HUP
+       RETVAL=$?
+}
+
+condrestart() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "GitLab Sidekiq"
+               RETVAL=$1
+               return
+       fi
+
+       stop
+       start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       status --pidfile $pidfile gitlab-sidekiq
+       RETVAL=$?
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/gitlab-unicorn.init b/gitlab-unicorn.init
new file mode 100755 (executable)
index 0000000..192f7ee
--- /dev/null
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# gitlab-unicorn       gitlab-unicorn short service description
+#
+# chkconfig:   345 82 18
+# description: Runs unicorn
+# processname: sidekiq
+#
+# Related (kudos @4sak3n0ne):
+# https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
+# https://gist.github.com/3062860
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "GitLab Unicorn"
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+### Environment variables
+RAILS_ENV="production"
+
+# The username and path to the gitlab source
+USER=git
+APP_PATH=/var/lib/gitlab
+
+# The PID and LOCK files used by unicorn and sidekiq
+pidfile=$APP_PATH/tmp/pids/unicorn.pid
+lockfile=/var/lock/subsys/gitlab-unicorn
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/gitlab-unicorn ] && . /etc/sysconfig/gitlab-unicorn
+
+start() {
+       # Check if the service is already running?
+       if [ -f $lockfile ]; then
+               msg_already_running "GitLab Unicorn"
+               return
+       fi
+
+       msg_starting "GitLab Unicorn"
+       daemon --pidfile $pidfile --user $USER --chdir "$APP_PATH" \
+               "env RAILS_ENV=$RAILS_ENV bin/web start"
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch $lockfile
+}
+
+stop() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "GitLab Unicorn"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "GitLab Unicorn"
+       killproc --pidfile $pidfile unicorn
+       rm -f $lockfile
+}
+
+reload() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "GitLab Unicorn"
+               RETVAL=7
+               return
+       fi
+
+       msg_reloading "GitLab Unicorn"
+       killproc <procname> -HUP
+       killproc --pidfile $pidfile <procname> -HUP
+       RETVAL=$?
+}
+
+condrestart() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "GitLab Unicorn"
+               RETVAL=$1
+               return
+       fi
+
+       stop
+       start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       status --pidfile $pidfile unicorn
+       RETVAL=$?
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL
This page took 0.042981 seconds and 4 git commands to generate.