summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-08-19 20:22:14 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-08-19 20:22:14 +0000
commit65cba5c6b91483f7f629c9bb2dcd98e2da92405c (patch)
treedbc47b8113f617a6f5c6f4aaf9b74591092a1873
parent4250c349152e252ff36bab54c53d7b267a5b1232 (diff)
parent63009af1176c114029827679c3eb632ad5edca26 (diff)
downloadgitlab-ce-65cba5c6b91483f7f629c9bb2dcd98e2da92405c.tar.gz
Merge branch 'init-script-should-restart-unicorn' of /home/git/repositories/gitlab/gitlabhq
-rw-r--r--.gitignore1
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock3
-rw-r--r--config/application.rb11
-rw-r--r--config/gitlab.yml.example10
-rw-r--r--config/puma.rb.example93
-rw-r--r--doc/make_release.md2
-rw-r--r--lib/support/init.d/gitlab18
-rw-r--r--lib/support/init.d/gitlab_unicorn138
9 files changed, 25 insertions, 254 deletions
diff --git a/.gitignore b/.gitignore
index de8b77ffd4b..b1dc17929f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,6 @@ config/gitlab.yml
config/database.yml
config/initializers/omniauth.rb
config/unicorn.rb
-config/puma.rb
config/resque.yml
config/aws.yml
db/data.yml
diff --git a/Gemfile b/Gemfile
index 45a4b35ed32..d950f43b205 100644
--- a/Gemfile
+++ b/Gemfile
@@ -76,8 +76,7 @@ gem "github-markup", "~> 0.7.4", require: 'github/markup'
# Asciidoc to HTML
gem "asciidoctor"
-# Servers
-gem "puma", '~> 2.3.1', group: :puma
+# Application server
gem "unicorn", '~> 4.6.3', group: :unicorn
# State machine
diff --git a/Gemfile.lock b/Gemfile.lock
index d8fc5f4578b..abec9243bce 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -331,8 +331,6 @@ GEM
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
- puma (2.3.1)
- rack (>= 1.1, < 2.0)
pygments.rb (0.4.2)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
@@ -608,7 +606,6 @@ DEPENDENCIES
pg
poltergeist (~> 1.3.0)
pry
- puma (~> 2.3.1)
quiet_assets (~> 1.0.1)
rack-mini-profiler
rails (= 3.2.13)
diff --git a/config/application.rb b/config/application.rb
index f3edca8c353..f7349fa009b 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -67,9 +67,14 @@ module Gitlab
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
-
- # Uncomment this if you are using a subdirectory
- # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed
+
+ # Uncomment and customize the last line to run in a non-root path
+ # WARNING: This feature is no longer supported
+ # Note that three settings need to be changed for this to work.
+ # 1) In your application.rb file: config.relative_url_root = "/gitlab"
+ # 2) In your gitlab.yml file: relative_url_root: /gitlab
+ # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT']
+ #
# config.relative_url_root = "/gitlab"
end
end
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index c73307cabf4..59a4d1fd41b 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -18,10 +18,14 @@ production: &base
host: localhost
port: 80
https: false
+
+ # Uncomment and customize the last line to run in a non-root path
# WARNING: This feature is no longer supported
- # Uncomment and customize to run in non-root path
- # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed
- # You need to uncomment config.relative_url_root in config/application.rb
+ # Note that three settings need to be changed for this to work.
+ # 1) In your application.rb file: config.relative_url_root = "/gitlab"
+ # 2) In your gitlab.yml file: relative_url_root: /gitlab
+ # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT']
+ #
# relative_url_root: /gitlab
# Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
diff --git a/config/puma.rb.example b/config/puma.rb.example
deleted file mode 100644
index c363ad010b6..00000000000
--- a/config/puma.rb.example
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env puma
-
-# Start Puma with next command:
-# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
-
-# uncomment and customize to run in non-root path
-# note that config/gitlab.yml web path should also be changed
-# ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
-
-application_path = '/home/git/gitlab'
-directory application_path
-environment 'production'
-daemonize true
-pidfile "#{application_path}/tmp/pids/puma.pid"
-state_path "#{application_path}/tmp/pids/puma.state"
-stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
-
-# Configure “min” to be the minimum number of threads to use to answer
-# requests and “max” the maximum.
-#
-# The default is “0, 16”.
-#
-# threads 0, 16
-
-# Bind the server to “url”. “tcp://”, “unix://” and “ssl://” are the only
-# accepted protocols.
-#
-# The default is “tcp://0.0.0.0:9292”.
-#
-# bind 'tcp://0.0.0.0:9292'
-# bind 'unix:///var/run/puma.sock'
-# bind 'unix:///var/run/puma.sock?umask=0777'
-# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
-bind "unix://#{application_path}/tmp/sockets/gitlab.socket"
-
-# Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you
-# can also use the “ssl_bind” option.
-#
-# ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert }
-
-# Code to run before doing a restart. This code should
-# close log files, database connections, etc.
-#
-# This can be called multiple times to add code each time.
-#
-# on_restart do
-# puts 'On restart...'
-# end
-
-# Command to use to restart puma. This should be just how to
-# load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
-# to puma, as those are the same as the original process.
-#
-# restart_command '/u/app/lolcat/bin/restart_puma'
-
-# === Cluster mode ===
-
-# How many worker processes to run.
-#
-# The default is “0”.
-#
-# workers 2
-
-# GitLab cluster mode recommendations
-# If you have more than 1 GB RAM, uncomment one of the following lines:
-#
-# workers 2 # if you have at least 1.5 GB RAM
-# workers 3 # if you have at least 2 GB RAM
-# workers 4 # if you have at least 2.5 GB RAM
-
-# Code to run when a worker boots to setup the process before booting
-# the app.
-#
-# This can be called multiple times to add hooks.
-#
-# on_worker_boot do
-# puts 'On worker boot...'
-# end
-
-# === Puma control rack application ===
-
-# Start the puma control rack application on “url”. This application can
-# be communicated with to control the main server. Additionally, you can
-# provide an authentication token, so all requests to the control server
-# will need to include that token as a query parameter. This allows for
-# simple authentication.
-#
-# Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb
-# to see what the app has available.
-#
-# activate_control_app 'unix:///var/run/pumactl.sock'
-# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
-# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
diff --git a/doc/make_release.md b/doc/make_release.md
index c93785e8750..5be0d5980a1 100644
--- a/doc/make_release.md
+++ b/doc/make_release.md
@@ -29,7 +29,7 @@ Check if any of these changed since last release (~22nd of last month depending
* https://github.com/gitlabhq/gitlabhq/commits/master/lib/support/nginx/gitlab
* https://github.com/gitlabhq/gitlab-shell/commits/master/config.yml.example
* https://github.com/gitlabhq/gitlabhq/commits/master/config/gitlab.yml.example
-* https://github.com/gitlabhq/gitlabhq/commits/master/config/puma.rb.example
+* https://github.com/gitlabhq/gitlabhq/commits/master/config/unicorn.rb.example
* https://github.com/gitlabhq/gitlabhq/commits/master/config/database.yml.mysql
* https://github.com/gitlabhq/gitlabhq/commits/master/config/database.yml.postgresql
diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab
index 2db37ed1c7d..29c9d98965d 100644
--- a/lib/support/init.d/gitlab
+++ b/lib/support/init.d/gitlab
@@ -2,7 +2,7 @@
# GITLAB
# Maintainer: @randx
-# App Version: 5.2
+# App Version: 6.0
### BEGIN INIT INFO
# Provides: gitlab
@@ -17,11 +17,10 @@
APP_ROOT="/home/git/gitlab"
APP_USER="git"
-DAEMON_OPTS="-C $APP_ROOT/config/puma.rb"
+DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production"
PID_PATH="$APP_ROOT/tmp/pids"
SOCKET_PATH="$APP_ROOT/tmp/sockets"
-SOCKET_FILE="$SOCKET_PATH/gitlab.socket"
-WEB_SERVER_PID="$PID_PATH/puma.pid"
+WEB_SERVER_PID="$PID_PATH/unicorn.pid"
SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
@@ -52,8 +51,8 @@ start() {
exit 1
else
if [ `whoami` = root ]; then
- ! [ -e $SOCKET_FILE ] || execute "rm $SOCKET_FILE"
- execute "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
+ execute "rm -f $SOCKET_PATH/gitlab.socket"
+ execute "RAILS_ENV=production bundle exec unicorn_rails $DAEMON_OPTS > /dev/null 2>&1 &"
execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
echo "$DESC started"
fi
@@ -66,13 +65,12 @@ stop() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
## Program is running, stop it.
kill -QUIT `cat $WEB_SERVER_PID`
- ! [ -e $SOCKET_FILE ] || execute "rm $SOCKET_FILE"
execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
rm "$WEB_SERVER_PID" >> /dev/null
echo "$DESC stopped"
else
## Program is not running, exit with error.
- echo "Error! $DESC is not started!"
+ echo "Error! $DESC not started!"
exit 1
fi
}
@@ -83,7 +81,7 @@ restart() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "Restarting $DESC..."
kill -USR2 `cat $WEB_SERVER_PID`
- execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1"
+ execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
if [ `whoami` = root ]; then
execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
fi
@@ -98,7 +96,7 @@ status() {
cd $APP_ROOT
check_pid
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
- echo "$DESC / Puma with PID $PID is running."
+ echo "$DESC / Unicorn with PID $PID is running."
echo "$DESC / Sidekiq with PID $SPID is running."
else
echo "$DESC is not running."
diff --git a/lib/support/init.d/gitlab_unicorn b/lib/support/init.d/gitlab_unicorn
deleted file mode 100644
index 219776c8684..00000000000
--- a/lib/support/init.d/gitlab_unicorn
+++ /dev/null
@@ -1,138 +0,0 @@
-#! /bin/bash
-
-# GITLAB
-# Maintainer: @randx
-# App Version: 6.0
-
-### BEGIN INIT INFO
-# Provides: gitlab
-# Required-Start: $local_fs $remote_fs $network $syslog redis-server
-# Required-Stop: $local_fs $remote_fs $network $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: GitLab git repository management
-# Description: GitLab git repository management
-### END INIT INFO
-
-
-APP_ROOT="/home/git/gitlab"
-APP_USER="git"
-DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production"
-PID_PATH="$APP_ROOT/tmp/pids"
-SOCKET_PATH="$APP_ROOT/tmp/sockets"
-WEB_SERVER_PID="$PID_PATH/unicorn.pid"
-SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
-STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
-START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
-NAME="gitlab"
-DESC="GitLab service"
-
-check_pid(){
- if [ -f $WEB_SERVER_PID ]; then
- PID=`cat $WEB_SERVER_PID`
- SPID=`cat $SIDEKIQ_PID`
- STATUS=`ps aux | grep $PID | grep -v grep | wc -l`
- else
- STATUS=0
- PID=0
- fi
-}
-
-execute() {
- sudo -u $APP_USER -H bash -l -c "$1"
-}
-
-start() {
- cd $APP_ROOT
- check_pid
- if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
- # Program is running, exit with error code 1.
- echo "Error! $DESC $NAME is currently running!"
- exit 1
- else
- if [ `whoami` = root ]; then
- execute "rm -f $SOCKET_PATH/gitlab.socket"
- execute "RAILS_ENV=production bundle exec unicorn_rails $DAEMON_OPTS > /dev/null 2>&1 &"
- execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
- echo "$DESC started"
- fi
- fi
-}
-
-stop() {
- cd $APP_ROOT
- check_pid
- if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
- ## Program is running, stop it.
- kill -QUIT `cat $WEB_SERVER_PID`
- execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
- rm "$WEB_SERVER_PID" >> /dev/null
- echo "$DESC stopped"
- else
- ## Program is not running, exit with error.
- echo "Error! $DESC not started!"
- exit 1
- fi
-}
-
-restart() {
- cd $APP_ROOT
- check_pid
- if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
- echo "Restarting $DESC..."
- kill -USR2 `cat $WEB_SERVER_PID`
- execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
- if [ `whoami` = root ]; then
- execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
- fi
- echo "$DESC restarted."
- else
- echo "Error, $NAME not running!"
- exit 1
- fi
-}
-
-status() {
- cd $APP_ROOT
- check_pid
- if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
- echo "$DESC / Puma with PID $PID is running."
- echo "$DESC / Sidekiq with PID $SPID is running."
- else
- echo "$DESC is not running."
- exit 1
- fi
-}
-
-## Check to see if we are running as root first.
-## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
-if [ "$(id -u)" != "0" ]; then
- echo "This script must be run as root"
- exit 1
-fi
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- reload|force-reload)
- echo -n "Reloading $NAME configuration: "
- kill -HUP `cat $PID`
- echo "done."
- ;;
- status)
- status
- ;;
- *)
- echo "Usage: sudo service gitlab {start|stop|restart|reload}" >&2
- exit 1
- ;;
-esac
-
-exit 0