Commit 3682e72619ab4dcccada2aeb14031e519fa3ce66
Exists in
spb-stable
and in
2 other branches
Merge branch 'move_script_to_bin' into 'master'
Move script to bin Fixes #925
Showing
14 changed files
with
149 additions
and
155 deletions
Show diff stats
README.md
| @@ -108,7 +108,7 @@ Start it with [Foreman](https://github.com/ddollar/foreman) | @@ -108,7 +108,7 @@ Start it with [Foreman](https://github.com/ddollar/foreman) | ||
| 108 | or start each component separately | 108 | or start each component separately |
| 109 | 109 | ||
| 110 | bundle exec rails s | 110 | bundle exec rails s |
| 111 | - script/background_jobs start | 111 | + bin/background_jobs start |
| 112 | 112 | ||
| 113 | And surf to [localhost:3000](http://localhost:3000/) and login with root / 5iveL!fe | 113 | And surf to [localhost:3000](http://localhost:3000/) and login with root / 5iveL!fe |
| 114 | 114 |
| @@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +cd $(dirname $0)/.. | ||
| 4 | +app_root=$(pwd) | ||
| 5 | +sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" | ||
| 6 | +sidekiq_logfile="$app_root/log/sidekiq.log" | ||
| 7 | +gitlab_user=$(ls -l config.ru | awk '{print $3}') | ||
| 8 | + | ||
| 9 | +function warn | ||
| 10 | +{ | ||
| 11 | + echo "$@" 1>&2 | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +function stop | ||
| 15 | +{ | ||
| 16 | + bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +function killall | ||
| 20 | +{ | ||
| 21 | + pkill -u $gitlab_user -f sidekiq | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +function restart | ||
| 25 | +{ | ||
| 26 | + if [ -f $sidekiq_pidfile ]; then | ||
| 27 | + stop | ||
| 28 | + fi | ||
| 29 | + killall | ||
| 30 | + start_sidekiq -d -L $sidekiq_logfile | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +function start_no_deamonize | ||
| 34 | +{ | ||
| 35 | + start_sidekiq | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +function start_sidekiq | ||
| 39 | +{ | ||
| 40 | + bundle exec sidekiq -q post_receive -q mailer -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1 | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +function load_ok | ||
| 44 | +{ | ||
| 45 | + sidekiq_pid=$(cat $sidekiq_pidfile) | ||
| 46 | + if [[ -z $sidekiq_pid ]] ; then | ||
| 47 | + warn "Could not find a PID in $sidekiq_pidfile" | ||
| 48 | + exit 0 | ||
| 49 | + fi | ||
| 50 | + | ||
| 51 | + if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then | ||
| 52 | + warn "Too many busy Sidekiq workers" | ||
| 53 | + exit 1 | ||
| 54 | + fi | ||
| 55 | + | ||
| 56 | + exit 0 | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +case "$1" in | ||
| 60 | + stop) | ||
| 61 | + stop | ||
| 62 | + ;; | ||
| 63 | + start) | ||
| 64 | + restart | ||
| 65 | + ;; | ||
| 66 | + start_no_deamonize) | ||
| 67 | + start_no_deamonize | ||
| 68 | + ;; | ||
| 69 | + restart) | ||
| 70 | + restart | ||
| 71 | + ;; | ||
| 72 | + killall) | ||
| 73 | + killall | ||
| 74 | + ;; | ||
| 75 | + load_ok) | ||
| 76 | + load_ok | ||
| 77 | + ;; | ||
| 78 | + *) | ||
| 79 | + echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall|load_ok}" | ||
| 80 | +esac |
| @@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +cd $(dirname $0)/.. | ||
| 4 | +app_root=$(pwd) | ||
| 5 | + | ||
| 6 | +unicorn_pidfile="$app_root/tmp/pids/unicorn.pid" | ||
| 7 | +unicorn_config="$app_root/config/unicorn.rb" | ||
| 8 | + | ||
| 9 | +function get_unicorn_pid | ||
| 10 | +{ | ||
| 11 | + local pid=$(cat $unicorn_pidfile) | ||
| 12 | + if [ -z $pid ] ; then | ||
| 13 | + echo "Could not find a PID in $unicorn_pidfile" | ||
| 14 | + exit 1 | ||
| 15 | + fi | ||
| 16 | + unicorn_pid=$pid | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +function start | ||
| 20 | +{ | ||
| 21 | + bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +function stop | ||
| 25 | +{ | ||
| 26 | + get_unicorn_pid | ||
| 27 | + kill -QUIT $unicorn_pid | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +function reload | ||
| 31 | +{ | ||
| 32 | + get_unicorn_pid | ||
| 33 | + kill -USR2 $unicorn_pid | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +case "$1" in | ||
| 37 | + start) | ||
| 38 | + start | ||
| 39 | + ;; | ||
| 40 | + stop) | ||
| 41 | + stop | ||
| 42 | + ;; | ||
| 43 | + reload) | ||
| 44 | + reload | ||
| 45 | + ;; | ||
| 46 | + *) | ||
| 47 | + echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}" | ||
| 48 | + ;; | ||
| 49 | +esac |
doc/update/upgrader.md
| @@ -19,10 +19,10 @@ __GitLab Upgrader is available only for GitLab version 6.4.2 or higher__ | @@ -19,10 +19,10 @@ __GitLab Upgrader is available only for GitLab version 6.4.2 or higher__ | ||
| 19 | ### 2. Run gitlab upgrade tool | 19 | ### 2. Run gitlab upgrade tool |
| 20 | 20 | ||
| 21 | cd /home/git/gitlab | 21 | cd /home/git/gitlab |
| 22 | - sudo -u git -H ruby script/upgrade.rb | 22 | + sudo -u git -H ruby bin/upgrade.rb |
| 23 | 23 | ||
| 24 | # to perform a non-interactive install (no user input required) you can add -y | 24 | # to perform a non-interactive install (no user input required) you can add -y |
| 25 | - # sudo -u git -H ruby script/upgrade.rb -y | 25 | + # sudo -u git -H ruby bin/upgrade.rb -y |
| 26 | 26 | ||
| 27 | ### 3. Start application | 27 | ### 3. Start application |
| 28 | 28 | ||
| @@ -57,6 +57,6 @@ You've read through the entire guide, and probably did all the steps manually. H | @@ -57,6 +57,6 @@ You've read through the entire guide, and probably did all the steps manually. H | ||
| 57 | 57 | ||
| 58 | ```bash | 58 | ```bash |
| 59 | cd /home/git/gitlab; sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \ | 59 | cd /home/git/gitlab; sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \ |
| 60 | - sudo service gitlab stop; sudo -u git -H ruby script/upgrade.rb -y; sudo service gitlab start; \ | 60 | + sudo service gitlab stop; sudo -u git -H ruby bin/upgrade.rb -y; sudo service gitlab start; \ |
| 61 | sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production | 61 | sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production |
| 62 | ``` | 62 | ``` |
lib/support/init.d/gitlab
| @@ -167,14 +167,14 @@ start_gitlab() { | @@ -167,14 +167,14 @@ start_gitlab() { | ||
| 167 | # Remove old socket if it exists | 167 | # Remove old socket if it exists |
| 168 | rm -f "$socket_path"/gitlab.socket 2>/dev/null | 168 | rm -f "$socket_path"/gitlab.socket 2>/dev/null |
| 169 | # Start the web server | 169 | # Start the web server |
| 170 | - RAILS_ENV=$RAILS_ENV script/web start | 170 | + RAILS_ENV=$RAILS_ENV bin/web start |
| 171 | fi | 171 | fi |
| 172 | 172 | ||
| 173 | # If sidekiq is already running, don't start it again. | 173 | # If sidekiq is already running, don't start it again. |
| 174 | if [ "$sidekiq_status" = "0" ]; then | 174 | if [ "$sidekiq_status" = "0" ]; then |
| 175 | echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting" | 175 | echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting" |
| 176 | else | 176 | else |
| 177 | - RAILS_ENV=$RAILS_ENV script/background_jobs start & | 177 | + RAILS_ENV=$RAILS_ENV bin/background_jobs start & |
| 178 | fi | 178 | fi |
| 179 | 179 | ||
| 180 | # Wait for the pids to be planted | 180 | # Wait for the pids to be planted |
| @@ -197,11 +197,11 @@ stop_gitlab() { | @@ -197,11 +197,11 @@ stop_gitlab() { | ||
| 197 | 197 | ||
| 198 | # If the Unicorn web server is running, tell it to stop; | 198 | # If the Unicorn web server is running, tell it to stop; |
| 199 | if [ "$web_status" = "0" ]; then | 199 | if [ "$web_status" = "0" ]; then |
| 200 | - RAILS_ENV=$RAILS_ENV script/web stop | 200 | + RAILS_ENV=$RAILS_ENV bin/web stop |
| 201 | fi | 201 | fi |
| 202 | # And do the same thing for the Sidekiq. | 202 | # And do the same thing for the Sidekiq. |
| 203 | if [ "$sidekiq_status" = "0" ]; then | 203 | if [ "$sidekiq_status" = "0" ]; then |
| 204 | - RAILS_ENV=$RAILS_ENV script/background_jobs stop | 204 | + RAILS_ENV=$RAILS_ENV bin/background_jobs stop |
| 205 | fi | 205 | fi |
| 206 | 206 | ||
| 207 | # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script. | 207 | # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script. |
| @@ -253,10 +253,10 @@ reload_gitlab(){ | @@ -253,10 +253,10 @@ reload_gitlab(){ | ||
| 253 | exit 1 | 253 | exit 1 |
| 254 | fi | 254 | fi |
| 255 | printf "Reloading GitLab Unicorn configuration... " | 255 | printf "Reloading GitLab Unicorn configuration... " |
| 256 | - RAILS_ENV=$RAILS_ENV script/web reload | 256 | + RAILS_ENV=$RAILS_ENV bin/web reload |
| 257 | echo "Done." | 257 | echo "Done." |
| 258 | echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..." | 258 | echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..." |
| 259 | - RAILS_ENV=$RAILS_ENV script/background_jobs restart | 259 | + RAILS_ENV=$RAILS_ENV bin/background_jobs restart |
| 260 | 260 | ||
| 261 | wait_for_pids | 261 | wait_for_pids |
| 262 | print_status | 262 | print_status |
lib/tasks/gitlab/check.rake
| @@ -637,7 +637,7 @@ namespace :gitlab do | @@ -637,7 +637,7 @@ namespace :gitlab do | ||
| 637 | else | 637 | else |
| 638 | puts "no".red | 638 | puts "no".red |
| 639 | try_fixing_it( | 639 | try_fixing_it( |
| 640 | - sudo_gitlab("RAILS_ENV=production script/background_jobs start") | 640 | + sudo_gitlab("RAILS_ENV=production bin/background_jobs start") |
| 641 | ) | 641 | ) |
| 642 | for_more_information( | 642 | for_more_information( |
| 643 | see_installation_guide_section("Install Init Script"), | 643 | see_installation_guide_section("Install Init Script"), |
lib/tasks/sidekiq.rake
| 1 | namespace :sidekiq do | 1 | namespace :sidekiq do |
| 2 | desc "GITLAB | Stop sidekiq" | 2 | desc "GITLAB | Stop sidekiq" |
| 3 | task :stop do | 3 | task :stop do |
| 4 | - system *%W(script/background_jobs stop) | 4 | + system *%W(bin/background_jobs stop) |
| 5 | end | 5 | end |
| 6 | 6 | ||
| 7 | desc "GITLAB | Start sidekiq" | 7 | desc "GITLAB | Start sidekiq" |
| 8 | task :start do | 8 | task :start do |
| 9 | - system *%W(script/background_jobs start) | 9 | + system *%W(bin/background_jobs start) |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | desc 'GitLab | Restart sidekiq' | 12 | desc 'GitLab | Restart sidekiq' |
| 13 | task :restart do | 13 | task :restart do |
| 14 | - system *%W(script/background_jobs restart) | 14 | + system *%W(bin/background_jobs restart) |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | desc "GITLAB | Start sidekiq with launchd on Mac OS X" | 17 | desc "GITLAB | Start sidekiq with launchd on Mac OS X" |
| 18 | task :launchd do | 18 | task :launchd do |
| 19 | - system *%W(script/background_jobs start_no_deamonize) | 19 | + system *%W(bin/background_jobs start_no_deamonize) |
| 20 | end | 20 | end |
| 21 | end | 21 | end |
script/background_jobs
| @@ -1,80 +0,0 @@ | @@ -1,80 +0,0 @@ | ||
| 1 | -#!/usr/bin/env bash | ||
| 2 | - | ||
| 3 | -cd $(dirname $0)/.. | ||
| 4 | -app_root=$(pwd) | ||
| 5 | -sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" | ||
| 6 | -sidekiq_logfile="$app_root/log/sidekiq.log" | ||
| 7 | -gitlab_user=$(ls -l config.ru | awk '{print $3}') | ||
| 8 | - | ||
| 9 | -function warn | ||
| 10 | -{ | ||
| 11 | - echo "$@" 1>&2 | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -function stop | ||
| 15 | -{ | ||
| 16 | - bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -function killall | ||
| 20 | -{ | ||
| 21 | - pkill -u $gitlab_user -f sidekiq | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -function restart | ||
| 25 | -{ | ||
| 26 | - if [ -f $sidekiq_pidfile ]; then | ||
| 27 | - stop | ||
| 28 | - fi | ||
| 29 | - killall | ||
| 30 | - start_sidekiq -d -L $sidekiq_logfile | ||
| 31 | -} | ||
| 32 | - | ||
| 33 | -function start_no_deamonize | ||
| 34 | -{ | ||
| 35 | - start_sidekiq | ||
| 36 | -} | ||
| 37 | - | ||
| 38 | -function start_sidekiq | ||
| 39 | -{ | ||
| 40 | - bundle exec sidekiq -q post_receive -q mailer -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1 | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -function load_ok | ||
| 44 | -{ | ||
| 45 | - sidekiq_pid=$(cat $sidekiq_pidfile) | ||
| 46 | - if [[ -z $sidekiq_pid ]] ; then | ||
| 47 | - warn "Could not find a PID in $sidekiq_pidfile" | ||
| 48 | - exit 0 | ||
| 49 | - fi | ||
| 50 | - | ||
| 51 | - if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then | ||
| 52 | - warn "Too many busy Sidekiq workers" | ||
| 53 | - exit 1 | ||
| 54 | - fi | ||
| 55 | - | ||
| 56 | - exit 0 | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -case "$1" in | ||
| 60 | - stop) | ||
| 61 | - stop | ||
| 62 | - ;; | ||
| 63 | - start) | ||
| 64 | - restart | ||
| 65 | - ;; | ||
| 66 | - start_no_deamonize) | ||
| 67 | - start_no_deamonize | ||
| 68 | - ;; | ||
| 69 | - restart) | ||
| 70 | - restart | ||
| 71 | - ;; | ||
| 72 | - killall) | ||
| 73 | - killall | ||
| 74 | - ;; | ||
| 75 | - load_ok) | ||
| 76 | - load_ok | ||
| 77 | - ;; | ||
| 78 | - *) | ||
| 79 | - echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall|load_ok}" | ||
| 80 | -esac |
script/check
script/rails
| @@ -1,6 +0,0 @@ | @@ -1,6 +0,0 @@ | ||
| 1 | -#!/usr/bin/env ruby | ||
| 2 | -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. | ||
| 3 | - | ||
| 4 | -APP_PATH = File.expand_path('../../config/application', __FILE__) | ||
| 5 | -require File.expand_path('../../config/boot', __FILE__) | ||
| 6 | -require 'rails/commands' |
script/upgrade.rb
script/web
| @@ -1,49 +0,0 @@ | @@ -1,49 +0,0 @@ | ||
| 1 | -#!/usr/bin/env bash | ||
| 2 | - | ||
| 3 | -cd $(dirname $0)/.. | ||
| 4 | -app_root=$(pwd) | ||
| 5 | - | ||
| 6 | -unicorn_pidfile="$app_root/tmp/pids/unicorn.pid" | ||
| 7 | -unicorn_config="$app_root/config/unicorn.rb" | ||
| 8 | - | ||
| 9 | -function get_unicorn_pid | ||
| 10 | -{ | ||
| 11 | - local pid=$(cat $unicorn_pidfile) | ||
| 12 | - if [ -z $pid ] ; then | ||
| 13 | - echo "Could not find a PID in $unicorn_pidfile" | ||
| 14 | - exit 1 | ||
| 15 | - fi | ||
| 16 | - unicorn_pid=$pid | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -function start | ||
| 20 | -{ | ||
| 21 | - bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -function stop | ||
| 25 | -{ | ||
| 26 | - get_unicorn_pid | ||
| 27 | - kill -QUIT $unicorn_pid | ||
| 28 | -} | ||
| 29 | - | ||
| 30 | -function reload | ||
| 31 | -{ | ||
| 32 | - get_unicorn_pid | ||
| 33 | - kill -USR2 $unicorn_pid | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -case "$1" in | ||
| 37 | - start) | ||
| 38 | - start | ||
| 39 | - ;; | ||
| 40 | - stop) | ||
| 41 | - stop | ||
| 42 | - ;; | ||
| 43 | - reload) | ||
| 44 | - reload | ||
| 45 | - ;; | ||
| 46 | - *) | ||
| 47 | - echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}" | ||
| 48 | - ;; | ||
| 49 | -esac |