Commit 1a9b0df76736553d955deb2e50cb9dd011c4d113

Authored by Jacob Vosmaer
1 parent 052a7cc9

Check whether only one sidekiq is running

Showing 1 changed file with 26 additions and 1 deletions   Show diff stats
lib/tasks/gitlab/check.rake
@@ -626,6 +626,7 @@ namespace :gitlab do @@ -626,6 +626,7 @@ namespace :gitlab do
626 start_checking "Sidekiq" 626 start_checking "Sidekiq"
627 627
628 check_sidekiq_running 628 check_sidekiq_running
  629 + only_one_sidekiq_running
629 630
630 finished_checking "Sidekiq" 631 finished_checking "Sidekiq"
631 end 632 end
@@ -637,7 +638,7 @@ namespace :gitlab do @@ -637,7 +638,7 @@ namespace :gitlab do
637 def check_sidekiq_running 638 def check_sidekiq_running
638 print "Running? ... " 639 print "Running? ... "
639 640
640 - if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d+\.\d+\.\d+.+$/) 641 + if sidekiq_process_match
641 puts "yes".green 642 puts "yes".green
642 else 643 else
643 puts "no".red 644 puts "no".red
@@ -651,6 +652,30 @@ namespace :gitlab do @@ -651,6 +652,30 @@ namespace :gitlab do
651 fix_and_rerun 652 fix_and_rerun
652 end 653 end
653 end 654 end
  655 +
  656 + def only_one_sidekiq_running
  657 + sidekiq_match = sidekiq_process_match
  658 + return unless sidekiq_match
  659 +
  660 + print 'Number of Sidekiq processes ... '
  661 + if sidekiq_match.length == 1
  662 + puts '1'.green
  663 + else
  664 + puts "#{sidekiq_match.length}".red
  665 + try_fixing_it(
  666 + 'Unless you are running another Rails application on this server there should only be one Sidekiq process.',
  667 + 'sudo service gitlab stop',
  668 + 'sudo pkill -f sidekiq',
  669 + 'sleep 10 && sudo pkill -9 -f sidekiq',
  670 + 'sudo service gitlab start'
  671 + )
  672 + fix_and_rerun
  673 + end
  674 + end
  675 +
  676 + def sidekiq_process_match
  677 + run_and_match("ps aux | grep -i sidekiq", /(sidekiq \d+\.\d+\.\d+.+$)/)
  678 + end
654 end 679 end
655 680
656 681