Commit 5ac5f586f8685368be9adb999297642feca1736e
1 parent
cbcfe12f
Exists in
master
and in
4 other branches
Move init.d and nginx default recipes in core library to save efforts trying kee…
…p sync between gitlab-recipes and gitlabhq
Showing
3 changed files
with
171 additions
and
2 deletions
Show diff stats
doc/install/installation.md
... | ... | @@ -200,7 +200,7 @@ Make sure to update username/password in config/database.yml. |
200 | 200 | |
201 | 201 | Download the init script (will be /etc/init.d/gitlab): |
202 | 202 | |
203 | - sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab | |
203 | + sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/init.d/gitlab | |
204 | 204 | sudo chmod +x /etc/init.d/gitlab |
205 | 205 | |
206 | 206 | Make GitLab start on boot: |
... | ... | @@ -241,7 +241,7 @@ If you can't or don't want to use Nginx as your web server, have a look at the |
241 | 241 | |
242 | 242 | Download an example site config: |
243 | 243 | |
244 | - sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab | |
244 | + sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/nginx/gitlab | |
245 | 245 | sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab |
246 | 246 | |
247 | 247 | Make sure to edit the config file to match your setup: | ... | ... |
... | ... | @@ -0,0 +1,131 @@ |
1 | +#! /bin/bash | |
2 | + | |
3 | +# GITLAB | |
4 | +# Maintainer: @randx | |
5 | +# App Version: 5.1 | |
6 | + | |
7 | +### BEGIN INIT INFO | |
8 | +# Provides: gitlab | |
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/git/gitlab" | |
19 | +DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production" | |
20 | +PID_PATH="$APP_ROOT/tmp/pids" | |
21 | +WEB_SERVER_PID="$PID_PATH/puma.pid" | |
22 | +SIDEKIQ_PID="$PID_PATH/sidekiq.pid" | |
23 | +STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop" | |
24 | +START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start" | |
25 | +NAME="gitlab" | |
26 | +DESC="Gitlab service" | |
27 | + | |
28 | +check_pid(){ | |
29 | + if [ -f $WEB_SERVER_PID ]; then | |
30 | + PID=`cat $WEB_SERVER_PID` | |
31 | + SPID=`cat $SIDEKIQ_PID` | |
32 | + STATUS=`ps aux | grep $PID | grep -v grep | wc -l` | |
33 | + else | |
34 | + STATUS=0 | |
35 | + PID=0 | |
36 | + fi | |
37 | +} | |
38 | + | |
39 | +start() { | |
40 | + cd $APP_ROOT | |
41 | + check_pid | |
42 | + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
43 | + # Program is running, exit with error code 1. | |
44 | + echo "Error! $DESC $NAME is currently running!" | |
45 | + exit 1 | |
46 | + else | |
47 | + 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 &" | |
50 | + echo "$DESC started" | |
51 | + fi | |
52 | + fi | |
53 | +} | |
54 | + | |
55 | +stop() { | |
56 | + cd $APP_ROOT | |
57 | + check_pid | |
58 | + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
59 | + ## Program is running, stop it. | |
60 | + kill -QUIT `cat $WEB_SERVER_PID` | |
61 | + sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | |
62 | + rm "$WEB_SERVER_PID" >> /dev/null | |
63 | + echo "$DESC stopped" | |
64 | + else | |
65 | + ## Program is not running, exit with error. | |
66 | + echo "Error! $DESC not started!" | |
67 | + exit 1 | |
68 | + fi | |
69 | +} | |
70 | + | |
71 | +restart() { | |
72 | + cd $APP_ROOT | |
73 | + check_pid | |
74 | + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
75 | + echo "Restarting $DESC..." | |
76 | + kill -USR2 `cat $WEB_SERVER_PID` | |
77 | + sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | |
78 | + if [ `whoami` = root ]; then | |
79 | + sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" | |
80 | + fi | |
81 | + echo "$DESC restarted." | |
82 | + else | |
83 | + echo "Error, $NAME not running!" | |
84 | + exit 1 | |
85 | + fi | |
86 | +} | |
87 | + | |
88 | +status() { | |
89 | + cd $APP_ROOT | |
90 | + check_pid | |
91 | + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
92 | + echo "$DESC / Unicorn with PID $PID is running." | |
93 | + echo "$DESC / Sidekiq with PID $SPID is running." | |
94 | + else | |
95 | + echo "$DESC is not running." | |
96 | + exit 1 | |
97 | + fi | |
98 | +} | |
99 | + | |
100 | +## Check to see if we are running as root first. | |
101 | +## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html | |
102 | +if [ "$(id -u)" != "0" ]; then | |
103 | + echo "This script must be run as root" | |
104 | + exit 1 | |
105 | +fi | |
106 | + | |
107 | +case "$1" in | |
108 | + start) | |
109 | + start | |
110 | + ;; | |
111 | + stop) | |
112 | + stop | |
113 | + ;; | |
114 | + restart) | |
115 | + restart | |
116 | + ;; | |
117 | + reload|force-reload) | |
118 | + echo -n "Reloading $NAME configuration: " | |
119 | + kill -HUP `cat $PID` | |
120 | + echo "done." | |
121 | + ;; | |
122 | + status) | |
123 | + status | |
124 | + ;; | |
125 | + *) | |
126 | + echo "Usage: sudo service gitlab {start|stop|restart|reload}" >&2 | |
127 | + exit 1 | |
128 | + ;; | |
129 | +esac | |
130 | + | |
131 | +exit 0 | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +# GITLAB | |
2 | +# Maintainer: @randx | |
3 | +# App Version: 5.0 | |
4 | + | |
5 | +upstream gitlab { | |
6 | + server unix:/home/git/gitlab/tmp/sockets/gitlab.socket; | |
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/git/gitlab/public; | |
13 | + | |
14 | + # individual nginx logs for this gitlab vhost | |
15 | + access_log /var/log/nginx/gitlab_access.log; | |
16 | + error_log /var/log/nginx/gitlab_error.log; | |
17 | + | |
18 | + location / { | |
19 | + # serve static files from defined root folder;. | |
20 | + # @gitlab is a named location for the upstream fallback, see below | |
21 | + try_files $uri $uri/index.html $uri.html @gitlab; | |
22 | + } | |
23 | + | |
24 | + # if a file, which is not found in the root folder is requested, | |
25 | + # then the proxy pass the request to the upsteam (gitlab unicorn) | |
26 | + location @gitlab { | |
27 | + proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 | |
28 | + proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 | |
29 | + proxy_redirect off; | |
30 | + | |
31 | + proxy_set_header X-Forwarded-Proto $scheme; | |
32 | + proxy_set_header Host $http_host; | |
33 | + proxy_set_header X-Real-IP $remote_addr; | |
34 | + | |
35 | + proxy_pass http://gitlab; | |
36 | + } | |
37 | +} | |
38 | + | ... | ... |