Skip to content
Newer
Older
100755 76 lines (62 sloc) 1.38 KB
a6026c9 @randx Gitlab cli for development need at first
randx authored
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)
4a6596a @randx Fixed bunch of js bugs with comments. Also added development tips
randx authored
25 system(resque_start_cmd)
a6026c9 @randx Gitlab cli for development need at first
randx authored
26 else
27 system(rails_start_cmd)
4a6596a @randx Fixed bunch of js bugs with comments. Also added development tips
randx authored
28 system(resque_dev_start_cmd)
a6026c9 @randx Gitlab cli for development need at first
randx authored
29 end
30 end
31
32 def stop
33 case @mode
34 when 'production';
35 system(unicorn_stop_cmd)
36 else
37 system(rails_stop_cmd)
38 end
39 system(resque_stop_cmd)
40 end
41
42 def rails_start_cmd
43 "bundle exec rails s -d"
44 end
45
46 def rails_stop_cmd
47 pid = File.join(@path, "tmp/pids/server.pid")
48 "kill -QUIT `cat #{pid}`"
49 end
50
51 def unicorn_start_cmd
52 unicorn_conf = File.join(@path, "config/unicorn.rb")
53 "bundle exec unicorn_rails -c #{unicorn_conf} -E production -D"
54 end
55
56 def unicorn_stop_cmd
57 pid = File.join(@path, "/tmp/pids/unicorn.pid")
58 "kill -QUIT `cat #{pid}`"
59 end
60
4a6596a @randx Fixed bunch of js bugs with comments. Also added development tips
randx authored
61 def resque_dev_start_cmd
62 "./resque_dev.sh > /dev/null 2>&1"
63 end
64
a6026c9 @randx Gitlab cli for development need at first
randx authored
65 def resque_start_cmd
66 "./resque.sh > /dev/null 2>&1"
67 end
68
69 def resque_stop_cmd
70 pid = File.join(@path, "tmp/pids/resque_worker.pid")
71 "kill -QUIT `cat #{pid}`"
72 end
73 end
74
75 GitlabCli.new.execute
Something went wrong with that request. Please try again.