foreman-tasks 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +0 -2
  3. data/app/assets/javascripts/{trigger_form.js → foreman_tasks/trigger_form.js} +0 -0
  4. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +6 -1
  5. data/app/controllers/foreman_tasks/tasks_controller.rb +16 -2
  6. data/app/lib/actions/proxy_action.rb +7 -0
  7. data/app/models/foreman_tasks/task/dynflow_task.rb +19 -4
  8. data/app/models/foreman_tasks/task/summarizer.rb +3 -1
  9. data/app/views/common/_trigger_form.html.erb +1 -1
  10. data/app/views/foreman_tasks/recurring_logics/index.html.erb +1 -2
  11. data/app/views/foreman_tasks/tasks/dashboard/_latest_tasks_in_error_warning.html.erb +1 -1
  12. data/app/views/foreman_tasks/tasks/dashboard/_tasks_status.html.erb +2 -0
  13. data/app/views/foreman_tasks/tasks/index.html.erb +1 -2
  14. data/config/routes.rb +1 -0
  15. data/foreman-tasks.gemspec +1 -3
  16. data/lib/foreman_tasks.rb +2 -1
  17. data/lib/foreman_tasks/dynflow.rb +2 -108
  18. data/lib/foreman_tasks/dynflow/configuration.rb +7 -142
  19. data/lib/foreman_tasks/dynflow/persistence.rb +3 -2
  20. data/lib/foreman_tasks/engine.rb +2 -2
  21. data/lib/foreman_tasks/version.rb +1 -1
  22. data/test/controllers/recurring_logics_controller_test.rb +14 -0
  23. data/test/controllers/tasks_controller_test.rb +17 -0
  24. data/test/unit/otp_manager_test.rb +70 -0
  25. metadata +12 -43
  26. data/bin/dynflow-executor +0 -71
  27. data/bin/foreman-tasks +0 -5
  28. data/deploy/foreman-tasks.init +0 -231
  29. data/deploy/foreman-tasks.service +0 -16
  30. data/deploy/foreman-tasks.sysconfig +0 -26
  31. data/lib/foreman_tasks/dynflow/daemon.rb +0 -143
  32. data/lib/foreman_tasks/tasks/dynflow.rake +0 -7
  33. data/test/unit/daemon_test.rb +0 -86
@@ -1,5 +1,5 @@
1
1
  module ForemanTasks
2
- # wrap the dynflow persistence to reflect the changes to execution plan
2
+ # Wrap the Dynflow persistence to reflect the changes to execution plan
3
3
  # in the Task model. This is probably a temporary solution and
4
4
  # Dynflow will probably get more events-based API but it should be enought
5
5
  # for start, until the requiements on the API are clear enough.
@@ -11,7 +11,8 @@ module ForemanTasks
11
11
  begin
12
12
  on_execution_plan_save(execution_plan_id, value)
13
13
  rescue => e
14
- Foreman::Logging.exception('Error on on_execution_plan_save event', e, :logger => 'foreman-tasks/dynflow')
14
+ Foreman::Logging.exception('Error on on_execution_plan_save event', e,
15
+ :logger => 'dynflow')
15
16
  end
16
17
  end
17
18
  ensure
@@ -20,7 +20,7 @@ module ForemanTasks
20
20
  assets_to_precompile =
21
21
  Dir.chdir(root) do
22
22
  Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
23
- f.split(File::SEPARATOR, 4).last.gsub(/\.scss\Z/, '')
23
+ f.split(File::SEPARATOR, 4).last
24
24
  end
25
25
  end
26
26
 
@@ -58,7 +58,7 @@ module ForemanTasks
58
58
  security_block :foreman_tasks do |_map|
59
59
  permission :view_foreman_tasks, { :'foreman_tasks/tasks' => [:auto_complete_search, :sub_tasks, :index, :show],
60
60
  :'foreman_tasks/api/tasks' => [:bulk_search, :show, :index, :summary] }, :resource_type => ForemanTasks::Task.name
61
- permission :edit_foreman_tasks, { :'foreman_tasks/tasks' => [:resume, :unlock, :force_unlock, :cancel_step, :cancel],
61
+ permission :edit_foreman_tasks, { :'foreman_tasks/tasks' => [:resume, :unlock, :force_unlock, :cancel_step, :cancel, :abort],
62
62
  :'foreman_tasks/api/tasks' => [:bulk_resume] }, :resource_type => ForemanTasks::Task.name
63
63
 
64
64
  permission :create_recurring_logics, {}, :resource_type => ForemanTasks::RecurringLogic.name
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.10.0'.freeze
2
+ VERSION = '0.10.1'.freeze
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'foreman_tasks_test_helper'
2
+
3
+ module ForemanTasks
4
+ class RecurringLogicsControllerTest < ActionController::TestCase
5
+ basic_index_test('recurring_logics')
6
+ basic_pagination_per_page_test
7
+
8
+ # rubocop:disable Style/AccessorMethodName
9
+ def get_factory_name
10
+ :recurring_logic
11
+ end
12
+ # rubocop:enable Style/AccessorMethodName
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ require 'foreman_tasks_test_helper'
2
+
3
+ module ForemanTasks
4
+ class TasksControllerTest < ActionController::TestCase
5
+ describe ForemanTasks::TasksController do
6
+ basic_index_test('tasks')
7
+ basic_pagination_per_page_test
8
+ basic_pagination_rendered_test
9
+
10
+ # rubocop:disable Style/AccessorMethodName
11
+ def get_factory_name
12
+ :dynflow_task
13
+ end
14
+ # rubocop:enable Style/AccessorMethodName
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,70 @@
1
+ require 'foreman_tasks_test_helper'
2
+ require 'foreman_tasks_core/otp_manager'
3
+
4
+ module ForemanTasksCore
5
+ class OtpManagerTest < ActiveSupport::TestCase
6
+ class TestOtpManager < OtpManager
7
+ def self.reset!
8
+ @passwords = nil
9
+ end
10
+ end
11
+
12
+ before do
13
+ TestOtpManager.reset!
14
+ end
15
+
16
+ let(:username) { 'myuser' }
17
+ let(:password) { '123456789' }
18
+ let(:base64) { 'bXl1c2VyOjEyMzQ1Njc4OQ==' }
19
+
20
+ it 'it doesn\'t raise when no passwords were generated yet' do
21
+ assert_nil TestOtpManager.drop_otp('missing', 'password')
22
+ end
23
+
24
+ it 'generates OTPs using SecureRandom.hex and converts them to strings' do
25
+ otp = 4
26
+ SecureRandom.stubs(:hex).returns(otp)
27
+ TestOtpManager.generate_otp(username).must_equal otp.to_s
28
+ end
29
+
30
+ it 'removes OTP only when correct username and password is provided' do
31
+ otp = TestOtpManager.generate_otp(username)
32
+ assert_nil TestOtpManager.drop_otp('wrong_username', 'wrong_password')
33
+ assert_nil TestOtpManager.drop_otp(username, 'wrong_password')
34
+ assert_nil TestOtpManager.drop_otp('wrong_username', otp)
35
+ TestOtpManager.drop_otp(username, otp).must_equal otp
36
+ end
37
+
38
+ it 'parses the hash correctly' do
39
+ SecureRandom.stubs(:hex).returns(password)
40
+ TestOtpManager.expects(:drop_otp).with(username, password.to_s)
41
+ TestOtpManager.authenticate(base64)
42
+ end
43
+
44
+ it 'authenticates correctly' do
45
+ SecureRandom.stubs(:hex).returns(password)
46
+ generated = TestOtpManager.generate_otp(username)
47
+
48
+ TestOtpManager.authenticate(base64).must_equal generated
49
+ end
50
+
51
+ it 'OTPs can be used only once' do
52
+ SecureRandom.stubs(:hex).returns(password)
53
+ generated = TestOtpManager.generate_otp(username)
54
+
55
+ TestOtpManager.authenticate(base64).must_equal generated
56
+ assert_nil TestOtpManager.authenticate(base64)
57
+ end
58
+
59
+ it 'creates token from username and password correctly' do
60
+ TestOtpManager.tokenize(username, password).must_equal base64
61
+ end
62
+
63
+ it 'overwrites old OTP when generating a new one for the same username' do
64
+ old = TestOtpManager.generate_otp(username)
65
+ new = TestOtpManager.generate_otp(username)
66
+ assert_nil TestOtpManager.drop_otp(username, old)
67
+ TestOtpManager.drop_otp(username, new).must_equal new
68
+ end
69
+ end
70
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-19 00:00:00.000000000 Z
11
+ date: 2017-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core
@@ -30,28 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.24
33
+ version: 0.8.26
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.24
41
- - !ruby/object:Gem::Dependency
42
- name: sequel
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: 0.8.26
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: sinatra
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +52,6 @@ dependencies:
66
52
  - - ">="
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: daemons
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: parse-cron
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +100,7 @@ files:
128
100
  - Gemfile
129
101
  - LICENSE
130
102
  - README.md
131
- - app/assets/javascripts/trigger_form.js
103
+ - app/assets/javascripts/foreman_tasks/trigger_form.js
132
104
  - app/assets/stylesheets/foreman_tasks/application.css.scss
133
105
  - app/assets/stylesheets/foreman_tasks/tasks.css.scss
134
106
  - app/assets/stylesheets/foreman_tasks/trigger_form.css
@@ -195,8 +167,6 @@ files:
195
167
  - app/views/foreman_tasks/tasks/dashboard/_tasks_status.html.erb
196
168
  - app/views/foreman_tasks/tasks/index.html.erb
197
169
  - app/views/foreman_tasks/tasks/show.html.erb
198
- - bin/dynflow-executor
199
- - bin/foreman-tasks
200
170
  - config/foreman-tasks.yaml.example
201
171
  - config/routes.rb
202
172
  - db/migrate/20131205204140_create_foreman_tasks.rb
@@ -215,9 +185,6 @@ files:
215
185
  - db/seeds.d/20-foreman_tasks_permissions.rb
216
186
  - db/seeds.d/60-dynflow_proxy_feature.rb
217
187
  - db/seeds.d/61-foreman_tasks_bookmarks.rb
218
- - deploy/foreman-tasks.init
219
- - deploy/foreman-tasks.service
220
- - deploy/foreman-tasks.sysconfig
221
188
  - extra/dynflow-debug.sh
222
189
  - extra/dynflow-executor.example
223
190
  - foreman-tasks.gemspec
@@ -228,12 +195,10 @@ files:
228
195
  - lib/foreman_tasks/dynflow.rb
229
196
  - lib/foreman_tasks/dynflow/configuration.rb
230
197
  - lib/foreman_tasks/dynflow/console_authorizer.rb
231
- - lib/foreman_tasks/dynflow/daemon.rb
232
198
  - lib/foreman_tasks/dynflow/persistence.rb
233
199
  - lib/foreman_tasks/engine.rb
234
200
  - lib/foreman_tasks/task_error.rb
235
201
  - lib/foreman_tasks/tasks/cleanup.rake
236
- - lib/foreman_tasks/tasks/dynflow.rake
237
202
  - lib/foreman_tasks/tasks/export_tasks.rake
238
203
  - lib/foreman_tasks/test_extensions.rb
239
204
  - lib/foreman_tasks/test_helpers.rb
@@ -248,6 +213,8 @@ files:
248
213
  - script/rails
249
214
  - test/controllers/api/recurring_logics_controller_test.rb
250
215
  - test/controllers/api/tasks_controller_test.rb
216
+ - test/controllers/recurring_logics_controller_test.rb
217
+ - test/controllers/tasks_controller_test.rb
251
218
  - test/factories/recurring_logic_factory.rb
252
219
  - test/factories/task_factory.rb
253
220
  - test/factories/triggering_factory.rb
@@ -259,8 +226,8 @@ files:
259
226
  - test/unit/actions/proxy_action_test.rb
260
227
  - test/unit/cleaner_test.rb
261
228
  - test/unit/config/environment.rb
262
- - test/unit/daemon_test.rb
263
229
  - test/unit/dynflow_console_authorizer_test.rb
230
+ - test/unit/otp_manager_test.rb
264
231
  - test/unit/proxy_selector_test.rb
265
232
  - test/unit/recurring_logic_test.rb
266
233
  - test/unit/task_groups_test.rb
@@ -285,13 +252,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
252
  version: '0'
286
253
  requirements: []
287
254
  rubyforge_project:
288
- rubygems_version: 2.4.5
255
+ rubygems_version: 2.6.12
289
256
  signing_key:
290
257
  specification_version: 4
291
258
  summary: Foreman plugin for showing tasks information for resoruces and users
292
259
  test_files:
293
260
  - test/controllers/api/recurring_logics_controller_test.rb
294
261
  - test/controllers/api/tasks_controller_test.rb
262
+ - test/controllers/recurring_logics_controller_test.rb
263
+ - test/controllers/tasks_controller_test.rb
295
264
  - test/factories/recurring_logic_factory.rb
296
265
  - test/factories/task_factory.rb
297
266
  - test/factories/triggering_factory.rb
@@ -303,8 +272,8 @@ test_files:
303
272
  - test/unit/actions/proxy_action_test.rb
304
273
  - test/unit/cleaner_test.rb
305
274
  - test/unit/config/environment.rb
306
- - test/unit/daemon_test.rb
307
275
  - test/unit/dynflow_console_authorizer_test.rb
276
+ - test/unit/otp_manager_test.rb
308
277
  - test/unit/proxy_selector_test.rb
309
278
  - test/unit/recurring_logic_test.rb
310
279
  - test/unit/task_groups_test.rb
@@ -1,71 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
-
5
- class ArgvParser
6
- attr_reader :options, :command
7
-
8
- def initialize(argv, file)
9
- @options = { foreman_root: Dir.pwd }
10
-
11
- opts = OptionParser.new do |opts|
12
- opts.banner = banner(file)
13
-
14
- opts.on('-h', '--help', 'Show this message') do
15
- puts opts
16
- exit 1
17
- end
18
- opts.on('-f', '--foreman-root=PATH', "Path to Foreman Rails root path. By default '#{@options[:foreman_root]}'") do |path|
19
- @options[:foreman_root] = path
20
- end
21
- opts.on('-c', '--executors-count=COUNT', 'Number of parallel executors to spawn. Overrides EXECUTORS_COUNT environment varaible.') do |count|
22
- @options[:executors_count] = count.to_i
23
- end
24
- opts.on('-m', '--memory-limit=SIZE', 'Limits the amount of memory an executor can consume. Overrides EXECUTOR_MEMORY_LIMIT environment varaible. You can use kb, mb, gb') do |size|
25
- @options[:memory_limit] = size
26
- end
27
- opts.on('--executor-memory-init-delay=SECONDS', 'Start memory polling after SECONDS. Overrides EXECUTOR_MEMORY_MONITOR_DELAY environment varaible.') do |seconds|
28
- @options[:memory_init_delay] = seconds.to_i
29
- end
30
- opts.on('--executor-memory-polling-interval=SECONDS', 'Check for memory useage every SECONDS sec. Overrides EXECUTOR_MEMORY_MONITOR_INTERVAL environment varaible.') do |seconds|
31
- @options[:memory_polling_interval] = seconds.to_i
32
- end
33
- end
34
-
35
- args = opts.parse!(argv)
36
- @command = args.first || 'run'
37
- end
38
-
39
- def banner(file)
40
- banner = <<BANNER
41
- Run Dynflow executor for Foreman tasks.
42
-
43
- Usage: #{File.basename(file)} [options] ACTION"
44
-
45
- ACTION can be one of:
46
-
47
- * start - start the executor on background. It creates these files
48
- in tmp/pid directory:
49
-
50
- * dynflow_executor_monitor.pid - pid of monitor ensuring
51
- the executor keeps running
52
- * dynflow_executor.pid - pid of the executor itself
53
- * dynflow_executor.output - stdout of the executor
54
- * stop - stops the running executor
55
- * restart - restarts the running executor
56
- * run - run the executor in foreground
57
-
58
- BANNER
59
- banner
60
- end
61
- end
62
-
63
- # run the script if it's executed explicitly
64
- if $PROGRAM_NAME == __FILE__
65
- parser = ArgvParser.new(ARGV, $PROGRAM_NAME)
66
-
67
- app_file = File.expand_path('./config/application', parser.options[:foreman_root])
68
- require app_file
69
-
70
- ForemanTasks::Dynflow::Daemon.new.run_background(parser.command, parser.options)
71
- end
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- foreman_root = '/usr/share/foreman'
4
- require File.expand_path('./config/application', foreman_root)
5
- ForemanTasks::Dynflow::Daemon.new.run_background(ARGV.last, :foreman_root => foreman_root)
@@ -1,231 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Init script for foreman-tasks
4
- #
5
- # chkconfig: - 88 12
6
- # description: Init script for foreman-tasks
7
- #
8
-
9
- # Source function library.
10
- . /etc/rc.d/init.d/functions
11
-
12
- if [ -f /etc/sysconfig/foreman-tasks ]; then
13
- . /etc/sysconfig/foreman-tasks
14
- fi
15
-
16
- prog=foreman-tasks
17
- RETVAL=0
18
- FOREMAN_USER=${FOREMAN_USER:-foreman}
19
- FOREMAN_HOME=${FOREMAN_HOME:-/usr/share/foreman}
20
- FOREMAN_DATA_DIR=${FOREMAN_DATA_DIR:-/var/lib/foreman}
21
- FOREMAN_ENV=${FOREMAN_ENV:-production}
22
- FOREMAN_TASK_PARAMS=${FOREMAN_TASK_PARAMS:--p foreman}
23
- FOREMAN_PID_DIR=$FOREMAN_HOME/tmp/pids
24
- FOREMAN_LOG_DIR=${FOREMAN_LOG_DIR:-/var/log/foreman}
25
- TASK_SCRIPT="/usr/bin/foreman-tasks"
26
- export RAILS_ENV=$FOREMAN_ENV
27
- export FOREMAN_LOGGING=${FOREMAN_LOGGING:-warn}
28
- export FOREMAN_LOGGING_SQL=${FOREMAN_LOGGING_SQL:-warn}
29
- export RAILS_RELATIVE_URL_ROOT=$FOREMAN_PREFIX
30
- export BUNDLER_EXT_GROUPS
31
- export BUNDLER_EXT_NOSTRICT
32
- export BUNDLER_EXT_HOME=$FOREMAN_HOME
33
-
34
- print_higher() {
35
- if [ 0$1 -gt 0$2 ]; then
36
- echo $1
37
- else
38
- echo $2
39
- fi
40
- }
41
-
42
- print_lower() {
43
- if [ 0$1 -gt 0$2 ]; then
44
- echo $2
45
- else
46
- echo $1
47
- fi
48
- }
49
-
50
- status_of_one() {
51
- PID_FILE="$1"
52
- local RC
53
- local RETVAL
54
- if [ -f "$PID_FILE" ]; then
55
- # set $pid
56
- __pids_var_run NOT_USED $PID_FILE
57
- RC=$?
58
- if [ -n "$pid" -o 0$RC -gt 0 ]; then
59
- RETVAL=2 # Program is dead and pid file exists
60
- fi
61
- #check if proces with pid from the file is running
62
- if checkpid $pid; then
63
- echo "running."
64
- RETVAL=0
65
- else
66
- echo "not running."
67
- RETVAL=1
68
- fi
69
- else
70
- echo "not running."
71
- RETVAL=3
72
- fi
73
- return $RETVAL
74
- }
75
-
76
- kstatus() {
77
- RETVAL=0
78
- SECONDVAL=256
79
- echo -n "dynflow_executor is "
80
- status_of_one $FOREMAN_PID_DIR/dynflow_executor.pid
81
- RC=$?
82
- RETVAL=$( print_higher $RC $RETVAL )
83
- SECONDVAL=$( print_lower $RC $SECONDVAL )
84
- echo -n "dynflow_executor_monitor is "
85
- status_of_one $FOREMAN_PID_DIR/dynflow_executor_monitor.pid
86
- RC=$?
87
- RETVAL=$( print_higher $RC $RETVAL )
88
- SECONDVAL=$( print_lower $RC $SECONDVAL )
89
- if [ 0$SECONDVAL -eq 0 -a 0$RETVAL -gt 0 ]; then
90
- # some is running, some not
91
- return 10
92
- else
93
- return $RETVAL
94
- fi
95
- }
96
-
97
- status_q() {
98
- kstatus &> /dev/null
99
- return $?
100
- }
101
-
102
- start() {
103
-
104
- echo -n $"Starting $prog: "
105
- status_q
106
- STATUS=$?
107
- if [ 0$STATUS -eq 0 ]; then
108
- echo -n $"$prog is already running. "
109
- RETVAL=0
110
- echo_success
111
- elif [ 0$STATUS -eq 10 ]; then
112
- echo -n $"Some processes of $prog is already running. Some not. Please stop $prog first."
113
- RETVAL=10
114
- echo_failure
115
- else
116
- # rails expects you to run from the root of the app
117
- pushd ${FOREMAN_HOME} >/dev/null
118
- # start jobs
119
- runuser -s /bin/bash - ${FOREMAN_USER} -c "\
120
- BUNDLER_EXT_NOSTRICT='$BUNDLER_EXT_NOSTRICT' \
121
- BUNDLER_EXT_HOME='$BUNDLER_EXT_HOME' \
122
- RAILS_RELATIVE_URL_ROOT='$RAILS_RELATIVE_URL_ROOT' \
123
- RAILS_ENV='$RAILS_ENV' \
124
- FOREMAN_LOGGING='$FOREMAN_LOGGING' \
125
- FOREMAN_LOGGING_SQL='$FOREMAN_LOGGING_SQL' \
126
- $TASK_SCRIPT $FOREMAN_TASK_PARAMS -m -n $FOREMAN_TASK_WORKERS start &>>${FOREMAN_LOG_DIR}/jobs-startup.log"
127
- RETVAL=$?
128
- if [ $RETVAL = 0 ]; then
129
- echo_success
130
- else
131
- echo_failure
132
- fi
133
- popd >/dev/null
134
- fi
135
-
136
- echo
137
- return $RETVAL
138
- }
139
-
140
- stop() {
141
-
142
- status_q
143
- STATUS=$?
144
- if [ 0$STATUS -eq 0 -o 0$STATUS -eq 10 ]; then
145
- # rails expects you to run from the root of the app
146
- pushd ${FOREMAN_HOME} >/dev/null
147
- runuser -s /bin/bash - ${FOREMAN_USER} -c "\
148
- BUNDLER_EXT_NOSTRICT='$BUNDLER_EXT_NOSTRICT' \
149
- BUNDLER_EXT_HOME='$BUNDLER_EXT_HOME' \
150
- RAILS_RELATIVE_URL_ROOT='$RAILS_RELATIVE_URL_ROOT' \
151
- RAILS_ENV='$RAILS_ENV' \
152
- FOREMAN_LOGGING='$FOREMAN_LOGGING' \
153
- FOREMAN_LOGGING_SQL='$FOREMAN_LOGGING_SQL' \
154
- $TASK_SCRIPT $FOREMAN_TASK_PARAMS -m -n $FOREMAN_TASK_WORKERS stop &>>${FOREMAN_LOG_DIR}/jobs-startup.log"
155
- if [ -f $FOREMAN_PID_DIR/dynflow_executor_monitor.pid ]; then
156
- echo -n $"Stopping dynflow_executor_monitor: "
157
- killproc -p $FOREMAN_PID_DIR/dynflow_executor_monitor.pid
158
- echo
159
- fi
160
- if [ -f $FOREMAN_PID_DIR/dynflow_executor.pid ]; then
161
- echo -n $"Stopping dynflow_executor: "
162
- killproc -p $FOREMAN_PID_DIR/dynflow_executor.pid
163
- echo
164
- fi
165
- popd >/dev/null
166
- RETVAL=0
167
- else
168
- RETVAL=0
169
- echo -n "Stopping $prog: "
170
- echo_failure
171
- echo
172
- fi
173
-
174
- return $RETVAL
175
- }
176
-
177
- restart() {
178
- stop
179
- start
180
- }
181
-
182
- condstop() {
183
- status_q
184
- STATUS=$?
185
- if [ 0$STATUS -eq 0 -o 0$STATUS -eq 10 ]; then
186
- stop
187
- else
188
- RETVAL=0
189
- fi
190
- }
191
-
192
- condrestart() {
193
- status_q
194
- STATUS=$?
195
- if [ 0$STATUS -eq 0 -o 0$STATUS -eq 10 ]; then
196
- restart
197
- else
198
- RETVAL=0
199
- fi
200
- }
201
-
202
- case "$1" in
203
- start)
204
- start
205
- ;;
206
- stop)
207
- stop
208
- ;;
209
- restart)
210
- restart
211
- ;;
212
- condrestart|try-restart)
213
- condrestart
214
- ;;
215
- condstop)
216
- condstop
217
- ;;
218
- status)
219
- kstatus
220
- RETVAL=$?
221
- ;;
222
- *)
223
- echo "Usage: {start|stop|restart|condrestart|condstop|status}"
224
- exit 1
225
- ;;
226
- esac
227
-
228
- exit $RETVAL
229
-
230
- # vim:set sw=4 ts=4 et:
231
-