Class: ForemanTasks::Dynflow
- Inherits:
-
Object
- Object
- ForemanTasks::Dynflow
show all
- Defined in:
- lib/foreman_tasks/dynflow.rb
Overview
Class for configuring and preparing the Dynflow runtime environment.
Defined Under Namespace
Classes: Configuration, ConsoleAuthorizer, Daemon, Persistence
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Dynflow.
12
13
14
|
# File 'lib/foreman_tasks/dynflow.rb', line 12
def initialize
@required = false
end
|
Instance Method Details
#eager_load_actions! ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/foreman_tasks/dynflow.rb', line 96
def eager_load_actions!
config.eager_load_paths.each do |load_path|
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
unless loaded_paths.include?(file)
require_dependency file
loaded_paths << file
end
end
end
@world.reload! if @world
end
|
#executor! ⇒ Object
Mark that the process is executor. This prevents the remote setting from applying. Needs to be set up before the world is being initialized
57
58
59
|
# File 'lib/foreman_tasks/dynflow.rb', line 57
def executor!
@executor = true
end
|
#executor? ⇒ Boolean
61
62
63
|
# File 'lib/foreman_tasks/dynflow.rb', line 61
def executor?
@executor
end
|
#initialize! ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/foreman_tasks/dynflow.rb', line 33
def initialize!
return unless @required
return @world if @world
if config.lazy_initialization && defined?(PhusionPassenger)
config.dynflow_logger.warn("ForemanTasks: lazy loading with PhusionPassenger might lead to unexpected results")
end
config.initialize_world.tap do |world|
@world = world
unless config.remote?
at_exit { world.terminate.wait }
if !Foreman.in_rake?('db:migrate') && (ForemanTasks::Task.table_exists? rescue(false))
world.auto_execute
ForemanTasks::Task::DynflowTask.consistency_check
end
end
end
end
|
#initialized? ⇒ Boolean
29
30
31
|
# File 'lib/foreman_tasks/dynflow.rb', line 29
def initialized?
!@world.nil?
end
|
#loaded_paths ⇒ Object
108
109
110
|
# File 'lib/foreman_tasks/dynflow.rb', line 108
def loaded_paths
@loaded_paths ||= Set.new
end
|
#reinitialize! ⇒ Object
65
66
67
68
|
# File 'lib/foreman_tasks/dynflow.rb', line 65
def reinitialize!
@world = nil
self.initialize!
end
|
#require! ⇒ Object
call this method if your engine uses Dynflow
21
22
23
|
# File 'lib/foreman_tasks/dynflow.rb', line 21
def require!
@required = true
end
|
#required? ⇒ Boolean
25
26
27
|
# File 'lib/foreman_tasks/dynflow.rb', line 25
def required?
@required
end
|
#web_console ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/foreman_tasks/dynflow.rb', line 83
def web_console
::Dynflow::Web.setup do
before do
if !Setting[:dynflow_enable_console] ||
(Setting[:dynflow_console_require_auth] && !ConsoleAuthorizer.new(env).allow?)
halt 403, 'Access forbidden'
end
end
set(:world) { ForemanTasks.dynflow.world }
end
end
|
#world ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/foreman_tasks/dynflow.rb', line 70
def world
return @world if @world
initialize! if config.lazy_initialization
unless @world
raise 'The Dynflow world was not initialized yet. '\
'If your plugin uses it, make sure to call ForemanTasks.dynflow.require! '\
'in some initializer'
end
return @world
end
|