From 2341cefd6fa2811a1af41f2068554738d7eebfc4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 27 May 2014 17:14:41 +0200 Subject: [PATCH] Move from script to bin directory. --- README.md | 2 +- bin/background_jobs | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/check | 2 ++ bin/upgrade.rb | 3 +++ bin/web | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/update/upgrader.md | 6 +++--- lib/support/init.d/gitlab | 12 ++++++------ lib/tasks/gitlab/check.rake | 2 +- lib/tasks/sidekiq.rake | 8 ++++---- script/background_jobs | 80 -------------------------------------------------------------------------------- script/check | 2 -- script/rails | 6 ------ script/upgrade.rb | 3 --- script/web | 49 ------------------------------------------------- 14 files changed, 149 insertions(+), 155 deletions(-) create mode 100755 bin/background_jobs create mode 100755 bin/check create mode 100644 bin/upgrade.rb create mode 100755 bin/web delete mode 100755 script/background_jobs delete mode 100755 script/check delete mode 100755 script/rails delete mode 100644 script/upgrade.rb delete mode 100755 script/web diff --git a/README.md b/README.md index 283336b..256f640 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Start it with [Foreman](https://github.com/ddollar/foreman) or start each component separately bundle exec rails s - script/background_jobs start + bin/background_jobs start And surf to [localhost:3000](http://localhost:3000/) and login with root / 5iveL!fe diff --git a/bin/background_jobs b/bin/background_jobs new file mode 100755 index 0000000..e0140e9 --- /dev/null +++ b/bin/background_jobs @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +cd $(dirname $0)/.. +app_root=$(pwd) +sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" +sidekiq_logfile="$app_root/log/sidekiq.log" +gitlab_user=$(ls -l config.ru | awk '{print $3}') + +function warn +{ + echo "$@" 1>&2 +} + +function stop +{ + bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 +} + +function killall +{ + pkill -u $gitlab_user -f sidekiq +} + +function restart +{ + if [ -f $sidekiq_pidfile ]; then + stop + fi + killall + start_sidekiq -d -L $sidekiq_logfile +} + +function start_no_deamonize +{ + start_sidekiq +} + +function start_sidekiq +{ + 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 +} + +function load_ok +{ + sidekiq_pid=$(cat $sidekiq_pidfile) + if [[ -z $sidekiq_pid ]] ; then + warn "Could not find a PID in $sidekiq_pidfile" + exit 0 + fi + + if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then + warn "Too many busy Sidekiq workers" + exit 1 + fi + + exit 0 +} + +case "$1" in + stop) + stop + ;; + start) + restart + ;; + start_no_deamonize) + start_no_deamonize + ;; + restart) + restart + ;; + killall) + killall + ;; + load_ok) + load_ok + ;; + *) + echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall|load_ok}" +esac diff --git a/bin/check b/bin/check new file mode 100755 index 0000000..c907a98 --- /dev/null +++ b/bin/check @@ -0,0 +1,2 @@ +#!/bin/sh +sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production diff --git a/bin/upgrade.rb b/bin/upgrade.rb new file mode 100644 index 0000000..a5caecf --- /dev/null +++ b/bin/upgrade.rb @@ -0,0 +1,3 @@ +require_relative "../lib/gitlab/upgrader" + +Gitlab::Upgrader.new.execute diff --git a/bin/web b/bin/web new file mode 100755 index 0000000..1ad3b5d --- /dev/null +++ b/bin/web @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +cd $(dirname $0)/.. +app_root=$(pwd) + +unicorn_pidfile="$app_root/tmp/pids/unicorn.pid" +unicorn_config="$app_root/config/unicorn.rb" + +function get_unicorn_pid +{ + local pid=$(cat $unicorn_pidfile) + if [ -z $pid ] ; then + echo "Could not find a PID in $unicorn_pidfile" + exit 1 + fi + unicorn_pid=$pid +} + +function start +{ + bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV +} + +function stop +{ + get_unicorn_pid + kill -QUIT $unicorn_pid +} + +function reload +{ + get_unicorn_pid + kill -USR2 $unicorn_pid +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload) + reload + ;; + *) + echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}" + ;; +esac diff --git a/doc/update/upgrader.md b/doc/update/upgrader.md index 72a94f6..d08c8b8 100644 --- a/doc/update/upgrader.md +++ b/doc/update/upgrader.md @@ -19,10 +19,10 @@ __GitLab Upgrader is available only for GitLab version 6.4.2 or higher__ ### 2. Run gitlab upgrade tool cd /home/git/gitlab - sudo -u git -H ruby script/upgrade.rb + sudo -u git -H ruby bin/upgrade.rb # to perform a non-interactive install (no user input required) you can add -y - # sudo -u git -H ruby script/upgrade.rb -y + # sudo -u git -H ruby bin/upgrade.rb -y ### 3. Start application @@ -48,6 +48,6 @@ You've read through the entire guide, and probably did all the steps manually. H ```bash cd /home/git/gitlab; sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \ - sudo service gitlab stop; sudo -u git -H ruby script/upgrade.rb -y; sudo service gitlab start; \ + sudo service gitlab stop; sudo -u git -H ruby bin/upgrade.rb -y; sudo service gitlab start; \ sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production ``` diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index 3dd4465..5c1ce2d 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -167,14 +167,14 @@ start_gitlab() { # Remove old socket if it exists rm -f "$socket_path"/gitlab.socket 2>/dev/null # Start the web server - RAILS_ENV=$RAILS_ENV script/web start + RAILS_ENV=$RAILS_ENV bin/web start fi # If sidekiq is already running, don't start it again. if [ "$sidekiq_status" = "0" ]; then echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting" else - RAILS_ENV=$RAILS_ENV script/background_jobs start & + RAILS_ENV=$RAILS_ENV bin/background_jobs start & fi # Wait for the pids to be planted @@ -197,11 +197,11 @@ stop_gitlab() { # If the Unicorn web server is running, tell it to stop; if [ "$web_status" = "0" ]; then - RAILS_ENV=$RAILS_ENV script/web stop + RAILS_ENV=$RAILS_ENV bin/web stop fi # And do the same thing for the Sidekiq. if [ "$sidekiq_status" = "0" ]; then - RAILS_ENV=$RAILS_ENV script/background_jobs stop + RAILS_ENV=$RAILS_ENV bin/background_jobs stop fi # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script. @@ -253,10 +253,10 @@ reload_gitlab(){ exit 1 fi printf "Reloading GitLab Unicorn configuration... " - RAILS_ENV=$RAILS_ENV script/web reload + RAILS_ENV=$RAILS_ENV bin/web reload echo "Done." echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..." - RAILS_ENV=$RAILS_ENV script/background_jobs restart + RAILS_ENV=$RAILS_ENV bin/background_jobs restart wait_for_pids print_status diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 0387795..ad5e04e 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -637,7 +637,7 @@ namespace :gitlab do else puts "no".red try_fixing_it( - sudo_gitlab("RAILS_ENV=production script/background_jobs start") + sudo_gitlab("RAILS_ENV=production bin/background_jobs start") ) for_more_information( see_installation_guide_section("Install Init Script"), diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake index ba806e5..e4bd654 100644 --- a/lib/tasks/sidekiq.rake +++ b/lib/tasks/sidekiq.rake @@ -1,21 +1,21 @@ namespace :sidekiq do desc "GITLAB | Stop sidekiq" task :stop do - system *%W(script/background_jobs stop) + system *%W(bin/background_jobs stop) end desc "GITLAB | Start sidekiq" task :start do - system *%W(script/background_jobs start) + system *%W(bin/background_jobs start) end desc 'GitLab | Restart sidekiq' task :restart do - system *%W(script/background_jobs restart) + system *%W(bin/background_jobs restart) end desc "GITLAB | Start sidekiq with launchd on Mac OS X" task :launchd do - system *%W(script/background_jobs start_no_deamonize) + system *%W(bin/background_jobs start_no_deamonize) end end diff --git a/script/background_jobs b/script/background_jobs deleted file mode 100755 index e0140e9..0000000 --- a/script/background_jobs +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -cd $(dirname $0)/.. -app_root=$(pwd) -sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" -sidekiq_logfile="$app_root/log/sidekiq.log" -gitlab_user=$(ls -l config.ru | awk '{print $3}') - -function warn -{ - echo "$@" 1>&2 -} - -function stop -{ - bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 -} - -function killall -{ - pkill -u $gitlab_user -f sidekiq -} - -function restart -{ - if [ -f $sidekiq_pidfile ]; then - stop - fi - killall - start_sidekiq -d -L $sidekiq_logfile -} - -function start_no_deamonize -{ - start_sidekiq -} - -function start_sidekiq -{ - 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 -} - -function load_ok -{ - sidekiq_pid=$(cat $sidekiq_pidfile) - if [[ -z $sidekiq_pid ]] ; then - warn "Could not find a PID in $sidekiq_pidfile" - exit 0 - fi - - if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then - warn "Too many busy Sidekiq workers" - exit 1 - fi - - exit 0 -} - -case "$1" in - stop) - stop - ;; - start) - restart - ;; - start_no_deamonize) - start_no_deamonize - ;; - restart) - restart - ;; - killall) - killall - ;; - load_ok) - load_ok - ;; - *) - echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall|load_ok}" -esac diff --git a/script/check b/script/check deleted file mode 100755 index c907a98..0000000 --- a/script/check +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production diff --git a/script/rails b/script/rails deleted file mode 100755 index f8da2cf..0000000 --- a/script/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' diff --git a/script/upgrade.rb b/script/upgrade.rb deleted file mode 100644 index a5caecf..0000000 --- a/script/upgrade.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative "../lib/gitlab/upgrader" - -Gitlab::Upgrader.new.execute diff --git a/script/web b/script/web deleted file mode 100755 index 1ad3b5d..0000000 --- a/script/web +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -cd $(dirname $0)/.. -app_root=$(pwd) - -unicorn_pidfile="$app_root/tmp/pids/unicorn.pid" -unicorn_config="$app_root/config/unicorn.rb" - -function get_unicorn_pid -{ - local pid=$(cat $unicorn_pidfile) - if [ -z $pid ] ; then - echo "Could not find a PID in $unicorn_pidfile" - exit 1 - fi - unicorn_pid=$pid -} - -function start -{ - bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV -} - -function stop -{ - get_unicorn_pid - kill -QUIT $unicorn_pid -} - -function reload -{ - get_unicorn_pid - kill -USR2 $unicorn_pid -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - reload) - reload - ;; - *) - echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}" - ;; -esac -- libgit2 0.21.2