3
3
4
4
Capistrano ::Configuration . instance ( :must_exist ) . load do
5
5
set :niet_process_count , 2
6
+ set :niet_roles , [ :job ]
6
7
7
8
def remote_file_exists? ( full_path )
8
9
'true' == capture ( "if [ -e #{ full_path } ]; then echo 'true'; fi" ) . strip
9
10
end
10
11
11
12
namespace :niet do
12
13
desc "Setup Niet"
13
- task :setup , roles : :job do
14
+ task :setup , roles : niet_roles do
14
15
run "mkdir -p #{ shared_path } /niet"
15
16
end
16
17
17
18
desc "Starts the niet process monitor and its jobs"
18
- task :start , roles : :job do
19
+ task :start , roles : niet_roles do
19
20
if remote_file_exists? ( "#{ shared_path } /niet" )
20
21
niet_process_count . times do |i |
21
22
run "niet -p #{ shared_path } /niet/jobs_worker_#{ i } .pid -c #{ current_path } bundle exec rake jobs:work RAILS_ENV=#{ stage } "
@@ -26,7 +27,7 @@ def remote_file_exists?(full_path)
26
27
end
27
28
28
29
desc "Restarts the processes running under niet"
29
- task :restart , roles : :job do
30
+ task :restart , roles : niet_roles do
30
31
if remote_file_exists? ( "#{ shared_path } /niet" )
31
32
run "for job in #{ shared_path } /niet/* ; do kill -TERM `cat $job`; done"
32
33
else
@@ -35,12 +36,12 @@ def remote_file_exists?(full_path)
35
36
end
36
37
37
38
desc "Stops the processes running under niet and the niet process monitor"
38
- task :stop , roles : :job do
39
+ task :stop , roles : niet_roles do
39
40
run "for job in #{ shared_path } /niet/* ; do kill -QUIT `cat $job`; done"
40
41
end
41
42
42
43
desc "Diplays the status of the niet process monitor"
43
- task :status , roles : :job do
44
+ task :status , roles : niet_roles do
44
45
run "for job in #{ shared_path } /niet/* ; do ps -fw `cat $job`; done"
45
46
end
46
47
end
0 commit comments