Commit 65cba5c6b91483f7f629c9bb2dcd98e2da92405c

Authored by Dmitriy Zaporozhets
2 parents 4250c349 63009af1

Merge branch 'init-script-should-restart-unicorn' of /home/git/repositories/gitlab/gitlabhq

.gitignore
... ... @@ -19,7 +19,6 @@ config/gitlab.yml
19 19 config/database.yml
20 20 config/initializers/omniauth.rb
21 21 config/unicorn.rb
22   -config/puma.rb
23 22 config/resque.yml
24 23 config/aws.yml
25 24 db/data.yml
... ...
Gemfile
... ... @@ -76,8 +76,7 @@ gem "github-markup", "~> 0.7.4", require: 'github/markup'
76 76 # Asciidoc to HTML
77 77 gem "asciidoctor"
78 78  
79   -# Servers
80   -gem "puma", '~> 2.3.1', group: :puma
  79 +# Application server
81 80 gem "unicorn", '~> 4.6.3', group: :unicorn
82 81  
83 82 # State machine
... ...
Gemfile.lock
... ... @@ -331,8 +331,6 @@ GEM
331 331 coderay (~> 1.0.5)
332 332 method_source (~> 0.8)
333 333 slop (~> 3.4)
334   - puma (2.3.1)
335   - rack (>= 1.1, < 2.0)
336 334 pygments.rb (0.4.2)
337 335 posix-spawn (~> 0.3.6)
338 336 yajl-ruby (~> 1.1.0)
... ... @@ -608,7 +606,6 @@ DEPENDENCIES
608 606 pg
609 607 poltergeist (~> 1.3.0)
610 608 pry
611   - puma (~> 2.3.1)
612 609 quiet_assets (~> 1.0.1)
613 610 rack-mini-profiler
614 611 rails (= 3.2.13)
... ...
config/application.rb
... ... @@ -67,9 +67,14 @@ module Gitlab
67 67  
68 68 # Version of your assets, change this if you want to expire all your assets
69 69 config.assets.version = '1.0'
70   -
71   - # Uncomment this if you are using a subdirectory
72   - # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed
  70 +
  71 + # Uncomment and customize the last line to run in a non-root path
  72 + # WARNING: This feature is no longer supported
  73 + # Note that three settings need to be changed for this to work.
  74 + # 1) In your application.rb file: config.relative_url_root = "/gitlab"
  75 + # 2) In your gitlab.yml file: relative_url_root: /gitlab
  76 + # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT']
  77 + #
73 78 # config.relative_url_root = "/gitlab"
74 79 end
75 80 end
... ...
config/gitlab.yml.example
... ... @@ -18,10 +18,14 @@ production: &amp;base
18 18 host: localhost
19 19 port: 80
20 20 https: false
  21 +
  22 + # Uncomment and customize the last line to run in a non-root path
21 23 # WARNING: This feature is no longer supported
22   - # Uncomment and customize to run in non-root path
23   - # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed
24   - # You need to uncomment config.relative_url_root in config/application.rb
  24 + # Note that three settings need to be changed for this to work.
  25 + # 1) In your application.rb file: config.relative_url_root = "/gitlab"
  26 + # 2) In your gitlab.yml file: relative_url_root: /gitlab
  27 + # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT']
  28 + #
25 29 # relative_url_root: /gitlab
26 30  
27 31 # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
... ...
config/puma.rb.example
... ... @@ -1,93 +0,0 @@
1   -#!/usr/bin/env puma
2   -
3   -# Start Puma with next command:
4   -# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
5   -
6   -# uncomment and customize to run in non-root path
7   -# note that config/gitlab.yml web path should also be changed
8   -# ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
9   -
10   -application_path = '/home/git/gitlab'
11   -directory application_path
12   -environment 'production'
13   -daemonize true
14   -pidfile "#{application_path}/tmp/pids/puma.pid"
15   -state_path "#{application_path}/tmp/pids/puma.state"
16   -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
17   -
18   -# Configure “min” to be the minimum number of threads to use to answer
19   -# requests and “max” the maximum.
20   -#
21   -# The default is “0, 16”.
22   -#
23   -# threads 0, 16
24   -
25   -# Bind the server to “url”. “tcp://”, “unix://” and “ssl://” are the only
26   -# accepted protocols.
27   -#
28   -# The default is “tcp://0.0.0.0:9292”.
29   -#
30   -# bind 'tcp://0.0.0.0:9292'
31   -# bind 'unix:///var/run/puma.sock'
32   -# bind 'unix:///var/run/puma.sock?umask=0777'
33   -# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
34   -bind "unix://#{application_path}/tmp/sockets/gitlab.socket"
35   -
36   -# Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you
37   -# can also use the “ssl_bind” option.
38   -#
39   -# ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert }
40   -
41   -# Code to run before doing a restart. This code should
42   -# close log files, database connections, etc.
43   -#
44   -# This can be called multiple times to add code each time.
45   -#
46   -# on_restart do
47   -# puts 'On restart...'
48   -# end
49   -
50   -# Command to use to restart puma. This should be just how to
51   -# load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
52   -# to puma, as those are the same as the original process.
53   -#
54   -# restart_command '/u/app/lolcat/bin/restart_puma'
55   -
56   -# === Cluster mode ===
57   -
58   -# How many worker processes to run.
59   -#
60   -# The default is “0”.
61   -#
62   -# workers 2
63   -
64   -# GitLab cluster mode recommendations
65   -# If you have more than 1 GB RAM, uncomment one of the following lines:
66   -#
67   -# workers 2 # if you have at least 1.5 GB RAM
68   -# workers 3 # if you have at least 2 GB RAM
69   -# workers 4 # if you have at least 2.5 GB RAM
70   -
71   -# Code to run when a worker boots to setup the process before booting
72   -# the app.
73   -#
74   -# This can be called multiple times to add hooks.
75   -#
76   -# on_worker_boot do
77   -# puts 'On worker boot...'
78   -# end
79   -
80   -# === Puma control rack application ===
81   -
82   -# Start the puma control rack application on “url”. This application can
83   -# be communicated with to control the main server. Additionally, you can
84   -# provide an authentication token, so all requests to the control server
85   -# will need to include that token as a query parameter. This allows for
86   -# simple authentication.
87   -#
88   -# Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb
89   -# to see what the app has available.
90   -#
91   -# activate_control_app 'unix:///var/run/pumactl.sock'
92   -# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
93   -# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
doc/make_release.md
... ... @@ -29,7 +29,7 @@ Check if any of these changed since last release (~22nd of last month depending
29 29 * https://github.com/gitlabhq/gitlabhq/commits/master/lib/support/nginx/gitlab
30 30 * https://github.com/gitlabhq/gitlab-shell/commits/master/config.yml.example
31 31 * https://github.com/gitlabhq/gitlabhq/commits/master/config/gitlab.yml.example
32   -* https://github.com/gitlabhq/gitlabhq/commits/master/config/puma.rb.example
  32 +* https://github.com/gitlabhq/gitlabhq/commits/master/config/unicorn.rb.example
33 33 * https://github.com/gitlabhq/gitlabhq/commits/master/config/database.yml.mysql
34 34 * https://github.com/gitlabhq/gitlabhq/commits/master/config/database.yml.postgresql
35 35  
... ...
lib/support/init.d/gitlab
... ... @@ -2,7 +2,7 @@
2 2  
3 3 # GITLAB
4 4 # Maintainer: @randx
5   -# App Version: 5.2
  5 +# App Version: 6.0
6 6  
7 7 ### BEGIN INIT INFO
8 8 # Provides: gitlab
... ... @@ -17,11 +17,10 @@
17 17  
18 18 APP_ROOT="/home/git/gitlab"
19 19 APP_USER="git"
20   -DAEMON_OPTS="-C $APP_ROOT/config/puma.rb"
  20 +DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production"
21 21 PID_PATH="$APP_ROOT/tmp/pids"
22 22 SOCKET_PATH="$APP_ROOT/tmp/sockets"
23   -SOCKET_FILE="$SOCKET_PATH/gitlab.socket"
24   -WEB_SERVER_PID="$PID_PATH/puma.pid"
  23 +WEB_SERVER_PID="$PID_PATH/unicorn.pid"
25 24 SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
26 25 STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
27 26 START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
... ... @@ -52,8 +51,8 @@ start() {
52 51 exit 1
53 52 else
54 53 if [ `whoami` = root ]; then
55   - ! [ -e $SOCKET_FILE ] || execute "rm $SOCKET_FILE"
56   - execute "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
  54 + execute "rm -f $SOCKET_PATH/gitlab.socket"
  55 + execute "RAILS_ENV=production bundle exec unicorn_rails $DAEMON_OPTS > /dev/null 2>&1 &"
57 56 execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
58 57 echo "$DESC started"
59 58 fi
... ... @@ -66,13 +65,12 @@ stop() {
66 65 if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
67 66 ## Program is running, stop it.
68 67 kill -QUIT `cat $WEB_SERVER_PID`
69   - ! [ -e $SOCKET_FILE ] || execute "rm $SOCKET_FILE"
70 68 execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
71 69 rm "$WEB_SERVER_PID" >> /dev/null
72 70 echo "$DESC stopped"
73 71 else
74 72 ## Program is not running, exit with error.
75   - echo "Error! $DESC is not started!"
  73 + echo "Error! $DESC not started!"
76 74 exit 1
77 75 fi
78 76 }
... ... @@ -83,7 +81,7 @@ restart() {
83 81 if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
84 82 echo "Restarting $DESC..."
85 83 kill -USR2 `cat $WEB_SERVER_PID`
86   - execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1"
  84 + execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
87 85 if [ `whoami` = root ]; then
88 86 execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
89 87 fi
... ... @@ -98,7 +96,7 @@ status() {
98 96 cd $APP_ROOT
99 97 check_pid
100 98 if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
101   - echo "$DESC / Puma with PID $PID is running."
  99 + echo "$DESC / Unicorn with PID $PID is running."
102 100 echo "$DESC / Sidekiq with PID $SPID is running."
103 101 else
104 102 echo "$DESC is not running."
... ...
lib/support/init.d/gitlab_unicorn
... ... @@ -1,138 +0,0 @@
1   -#! /bin/bash
2   -
3   -# GITLAB
4   -# Maintainer: @randx
5   -# App Version: 6.0
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   -APP_USER="git"
20   -DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production"
21   -PID_PATH="$APP_ROOT/tmp/pids"
22   -SOCKET_PATH="$APP_ROOT/tmp/sockets"
23   -WEB_SERVER_PID="$PID_PATH/unicorn.pid"
24   -SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
25   -STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
26   -START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
27   -NAME="gitlab"
28   -DESC="GitLab service"
29   -
30   -check_pid(){
31   - if [ -f $WEB_SERVER_PID ]; then
32   - PID=`cat $WEB_SERVER_PID`
33   - SPID=`cat $SIDEKIQ_PID`
34   - STATUS=`ps aux | grep $PID | grep -v grep | wc -l`
35   - else
36   - STATUS=0
37   - PID=0
38   - fi
39   -}
40   -
41   -execute() {
42   - sudo -u $APP_USER -H bash -l -c "$1"
43   -}
44   -
45   -start() {
46   - cd $APP_ROOT
47   - check_pid
48   - if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
49   - # Program is running, exit with error code 1.
50   - echo "Error! $DESC $NAME is currently running!"
51   - exit 1
52   - else
53   - if [ `whoami` = root ]; then
54   - execute "rm -f $SOCKET_PATH/gitlab.socket"
55   - execute "RAILS_ENV=production bundle exec unicorn_rails $DAEMON_OPTS > /dev/null 2>&1 &"
56   - execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
57   - echo "$DESC started"
58   - fi
59   - fi
60   -}
61   -
62   -stop() {
63   - cd $APP_ROOT
64   - check_pid
65   - if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
66   - ## Program is running, stop it.
67   - kill -QUIT `cat $WEB_SERVER_PID`
68   - execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
69   - rm "$WEB_SERVER_PID" >> /dev/null
70   - echo "$DESC stopped"
71   - else
72   - ## Program is not running, exit with error.
73   - echo "Error! $DESC not started!"
74   - exit 1
75   - fi
76   -}
77   -
78   -restart() {
79   - cd $APP_ROOT
80   - check_pid
81   - if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
82   - echo "Restarting $DESC..."
83   - kill -USR2 `cat $WEB_SERVER_PID`
84   - execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
85   - if [ `whoami` = root ]; then
86   - execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
87   - fi
88   - echo "$DESC restarted."
89   - else
90   - echo "Error, $NAME not running!"
91   - exit 1
92   - fi
93   -}
94   -
95   -status() {
96   - cd $APP_ROOT
97   - check_pid
98   - if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
99   - echo "$DESC / Puma with PID $PID is running."
100   - echo "$DESC / Sidekiq with PID $SPID is running."
101   - else
102   - echo "$DESC is not running."
103   - exit 1
104   - fi
105   -}
106   -
107   -## Check to see if we are running as root first.
108   -## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
109   -if [ "$(id -u)" != "0" ]; then
110   - echo "This script must be run as root"
111   - exit 1
112   -fi
113   -
114   -case "$1" in
115   - start)
116   - start
117   - ;;
118   - stop)
119   - stop
120   - ;;
121   - restart)
122   - restart
123   - ;;
124   - reload|force-reload)
125   - echo -n "Reloading $NAME configuration: "
126   - kill -HUP `cat $PID`
127   - echo "done."
128   - ;;
129   - status)
130   - status
131   - ;;
132   - *)
133   - echo "Usage: sudo service gitlab {start|stop|restart|reload}" >&2
134   - exit 1
135   - ;;
136   -esac
137   -
138   -exit 0