[packages/gitlab-workhorse] add sysv initscript; works for me rel 1

glen glen at pld-linux.org
Sun Sep 4 13:59:08 CEST 2016


commit 913d015a52a2e4f01bf946291a5be472fda72728
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Sep 4 14:58:26 2016 +0300

    add sysv initscript; works for me rel 1

 gitlab-workhorse.init | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gitlab-workhorse.spec |  16 +++++---
 2 files changed, 119 insertions(+), 5 deletions(-)
---
diff --git a/gitlab-workhorse.spec b/gitlab-workhorse.spec
index d99ed22..b7201f8 100644
--- a/gitlab-workhorse.spec
+++ b/gitlab-workhorse.spec
@@ -1,11 +1,11 @@
 Summary:	An HTTP daemon that serves Git clients
 Name:		gitlab-workhorse
 Version:	0.7.11
-Release:	0.7
+Release:	1
 License:	MIT
 Group:		Development/Building
-# md5 deliberately omitted until this package is useful
 Source0:	https://gitlab.com/gitlab-org/gitlab-workhorse/repository/archive.tar.gz?ref=v%{version}&/%{name}-%{version}.tar.gz
+# Source0-md5:	182135dd2174198e33a2660a02545e4d
 Source1:	%{name}.service
 URL:		https://gitlab.com/gitlab-org/gitlab-workhorse
 BuildRequires:	git-core
@@ -46,12 +46,18 @@ cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%preun
-%systemd_preun %{name}.service
-
 %post
+/sbin/chkconfig --add %{name}
+%service %{name} restart
 %systemd_post %{name}.service
 
+%preun
+if [ "$1" = "0" ]; then
+	%service -q %{name} stop
+	/sbin/chkconfig --del %{name}
+fi
+%systemd_preun %{name}.service
+
 %postun
 %systemd_reload
 
diff --git a/gitlab-workhorse.init b/gitlab-workhorse.init
new file mode 100755
index 0000000..f6590ea
--- /dev/null
+++ b/gitlab-workhorse.init
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# gitlab-workhorse GitLab Workhorse
+#
+# chkconfig:	345 82 18
+# description: Runs GitLab Workhorse
+# processname: gitlab-workhorse
+
+# 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 Workhorse"
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+### Environment variables
+RAILS_ENV="production"
+
+# The username and path to the gitlab source
+USER=git
+APP_PATH=/usr/lib/gitlab
+
+# The PID and LOCK files
+pidfile=$APP_PATH/tmp/pids/gitlab-workhorse.pid
+lockfile=/var/lock/subsys/gitlab-workhorse
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/gitlab-workhorse ] && . /etc/sysconfig/gitlab-workhorse
+
+start() {
+	# Check if the service is already running?
+	if [ -f $lockfile ]; then
+		msg_already_running "GitLab Workhorse"
+		return
+	fi
+
+	msg_starting "GitLab Workhorse"
+	daemon --pidfile $pidfile --user $USER --makepid --chdir "$APP_PATH" --fork \
+		/usr/sbin/gitlab-workhorse -listenUmask 0 \
+			-authBackend http://localhost:8080 -authSocket /var/run/gitlab/gitlab.socket \
+			-documentRoot /usr/lib/gitlab/public \
+			-listenNetwork unix -listenAddr /var/run/gitlab/gitlab-workhorse.socket
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch $lockfile
+}
+
+stop() {
+	if [ ! -f $lockfile ]; then
+		msg_not_running "GitLab Workhorse"
+		return
+	fi
+
+	# Stop daemons.
+	msg_stopping "GitLab Workhorse"
+	killproc --pidfile $pidfile gitlab-workhorse
+	RETVAL=$?
+	rm -f $lockfile
+}
+
+condrestart() {
+	if [ ! -f $lockfile ]; then
+		msg_not_running "GitLab Workhorse"
+		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-workhorse
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+	exit 3
+esac
+
+exit $RETVAL
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gitlab-workhorse.git/commitdiff/913d015a52a2e4f01bf946291a5be472fda72728



More information about the pld-cvs-commit mailing list