Commit a6026c9c8237020370e5499db5afb7ddab58532f
1 parent
4e474028
Exists in
master
and in
4 other branches
Gitlab cli for development need at first
Showing
1 changed file
with
70 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | + | |
| 3 | +class GitlabCli | |
| 4 | + def initialize | |
| 5 | + @path = File.dirname(__FILE__) | |
| 6 | + @command = ARGV.shift | |
| 7 | + @mode = ARGV.shift | |
| 8 | + end | |
| 9 | + | |
| 10 | + def execute | |
| 11 | + case @command | |
| 12 | + when 'start' then start | |
| 13 | + when 'stop' then stop | |
| 14 | + else | |
| 15 | + puts "-- Usage gitlab start production or gitlab stop development" | |
| 16 | + end | |
| 17 | + end | |
| 18 | + | |
| 19 | + private | |
| 20 | + | |
| 21 | + def start | |
| 22 | + case @mode | |
| 23 | + when 'production'; | |
| 24 | + system(unicorn_start_cmd) | |
| 25 | + else | |
| 26 | + system(rails_start_cmd) | |
| 27 | + end | |
| 28 | + system(resque_start_cmd) | |
| 29 | + end | |
| 30 | + | |
| 31 | + def stop | |
| 32 | + case @mode | |
| 33 | + when 'production'; | |
| 34 | + system(unicorn_stop_cmd) | |
| 35 | + else | |
| 36 | + system(rails_stop_cmd) | |
| 37 | + end | |
| 38 | + system(resque_stop_cmd) | |
| 39 | + end | |
| 40 | + | |
| 41 | + def rails_start_cmd | |
| 42 | + "bundle exec rails s -d" | |
| 43 | + end | |
| 44 | + | |
| 45 | + def rails_stop_cmd | |
| 46 | + pid = File.join(@path, "tmp/pids/server.pid") | |
| 47 | + "kill -QUIT `cat #{pid}`" | |
| 48 | + end | |
| 49 | + | |
| 50 | + def unicorn_start_cmd | |
| 51 | + unicorn_conf = File.join(@path, "config/unicorn.rb") | |
| 52 | + "bundle exec unicorn_rails -c #{unicorn_conf} -E production -D" | |
| 53 | + end | |
| 54 | + | |
| 55 | + def unicorn_stop_cmd | |
| 56 | + pid = File.join(@path, "/tmp/pids/unicorn.pid") | |
| 57 | + "kill -QUIT `cat #{pid}`" | |
| 58 | + end | |
| 59 | + | |
| 60 | + def resque_start_cmd | |
| 61 | + "./resque.sh > /dev/null 2>&1" | |
| 62 | + end | |
| 63 | + | |
| 64 | + def resque_stop_cmd | |
| 65 | + pid = File.join(@path, "tmp/pids/resque_worker.pid") | |
| 66 | + "kill -QUIT `cat #{pid}`" | |
| 67 | + end | |
| 68 | +end | |
| 69 | + | |
| 70 | +GitlabCli.new.execute | ... | ... |