Skip to content

Commit 7adc70f

Browse files
committed
Versions up. gitlab-ci recipes
1 parent 0dd5a61 commit 7adc70f

File tree

4 files changed

+159
-2
lines changed

4 files changed

+159
-2
lines changed

gitlab-ci/init.d/gitlab_ci

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#! /bin/bash
2+
3+
# GITLAB CI
4+
# Maintainer: @randx
5+
# App Version: 1.1
6+
7+
### BEGIN INIT INFO
8+
# Provides: gitlab_ci
9+
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
10+
# Required-Stop: $local_fs $remote_fs $network $syslog
11+
# Default-Start: 2 3 4 5
12+
# Default-Stop: 0 1 6
13+
# Short-Description: GitLab git repository management
14+
# Description: GitLab git repository management
15+
### END INIT INFO
16+
17+
18+
APP_ROOT="/home/gitlab_ci/gitlab-ci"
19+
DAEMON_OPTS="-p 3000 -d -e production"
20+
PID_PATH="$APP_ROOT/tmp/pids"
21+
THIN_PID="$PID_PATH/thin.pid"
22+
RESQUE_PID="$PID_PATH/resque_worker.pid"
23+
NAME="thin"
24+
DESC="Gitlab CI service"
25+
26+
check_pid(){
27+
if [ -f $THIN_PID ]; then
28+
PID=`cat $THIN_PID`
29+
STATUS=`ps aux | grep $PID | grep -v grep | wc -l`
30+
else
31+
STATUS=0
32+
PID=0
33+
fi
34+
}
35+
36+
start() {
37+
cd $APP_ROOT
38+
check_pid
39+
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
40+
# Program is running, exit with error code 1.
41+
echo "Error! $DESC $NAME is currently running!"
42+
exit 1
43+
else
44+
if [ `whoami` = root ]; then
45+
sudo -u gitlab_ci -H sh -l -c "nohup bundle exec thin start $DAEMON_OPTS > /dev/null 2>&1 &"
46+
sudo -u gitlab_ci -H sh -l -c "mkdir -p $PID_PATH && nohup bundle exec rake environment resque:work QUEUE=runner RAILS_ENV=production PIDFILE=$RESQUE_PID > /dev/null 2>&1 &"
47+
echo "$DESC started"
48+
fi
49+
fi
50+
}
51+
52+
stop() {
53+
cd $APP_ROOT
54+
check_pid
55+
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
56+
## Program is running, stop it.
57+
kill -QUIT `cat $THIN_PID`
58+
kill -QUIT `cat $RESQUE_PID`
59+
rm "$THIN_PID" >> /dev/null
60+
rm "$RESQUE_PID" >> /dev/null
61+
echo "$DESC stopped"
62+
else
63+
## Program is not running, exit with error.
64+
echo "Error! $DESC not started!"
65+
exit 1
66+
fi
67+
}
68+
69+
restart() {
70+
cd $APP_ROOT
71+
check_pid
72+
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
73+
echo -n "Restarting $DESC: "
74+
kill -USR2 `cat $THIN_PID`
75+
kill -USR2 `cat $RESQUE_PID`
76+
echo "$NAME."
77+
else
78+
echo "Error, $NAME not running!"
79+
exit 1
80+
fi
81+
}
82+
83+
status() {
84+
cd $APP_ROOT
85+
check_pid
86+
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
87+
echo "$DESC with PID $PID is running."
88+
else
89+
echo "$DESC is not running."
90+
exit 1
91+
fi
92+
}
93+
94+
## Check to see if we are running as root first.
95+
## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
96+
if [ "$(id -u)" != "0" ]; then
97+
echo "This script must be run as root"
98+
exit 1
99+
fi
100+
101+
case "$1" in
102+
start)
103+
start
104+
;;
105+
stop)
106+
stop
107+
;;
108+
restart)
109+
restart
110+
;;
111+
reload|force-reload)
112+
echo -n "Reloading $DESC configuration: "
113+
kill -HUP `cat $PID`
114+
echo "$NAME."
115+
;;
116+
status)
117+
status
118+
;;
119+
*)
120+
echo "Usage: $NAME {start|stop|restart|reload}" >&2
121+
exit 1
122+
;;
123+
esac
124+
125+
exit 0

gitlab-ci/nginx/gitlab_ci

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# GITLAB CI
2+
# Maintainer: @randx
3+
# App Version: 1.1
4+
5+
upstream gitlab_ci {
6+
server 127.0.0.1:3000;
7+
}
8+
9+
server {
10+
listen YOUR_SERVER_IP:80 default_server; # e.g., listen 192.168.1.1:80;
11+
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
12+
root /home/gitlab_ci/gitlab-ci/public;
13+
14+
access_log /var/log/nginx/gitlab_ci_access.log;
15+
error_log /var/log/nginx/gitlab_ci_error.log;
16+
17+
location / {
18+
try_files $uri $uri/index.html $uri.html @gitlab_ci;
19+
}
20+
21+
location @gitlab_ci {
22+
proxy_read_timeout 300;
23+
proxy_connect_timeout 300;
24+
proxy_redirect off;
25+
26+
proxy_set_header X-Forwarded-Proto $scheme;
27+
proxy_set_header Host $http_host;
28+
proxy_set_header X-Real-IP $remote_addr;
29+
30+
proxy_pass http://gitlab_ci;
31+
}
32+
}

init.d/gitlab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# GITLAB
44
# Maintainer: @randx
5-
# App Version: 3.0
5+
# App Version: 4.0
66

77
### BEGIN INIT INFO
88
# Provides: gitlab

nginx/gitlab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GITLAB
22
# Maintainer: @randx
3-
# App Version: 3.0
3+
# App Version: 4.0
44

55
upstream gitlab {
66
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;

0 commit comments

Comments
 (0)