Class: Wakame::Actions::StopService
- Inherits:
-
Wakame::Action
- Object
- Wakame::Action
- Wakame::Actions::StopService
- Defined in:
- lib/wakame/actions/stop_service.rb
Constant Summary
Constants included from AttributeHelper
AttributeHelper::CLASS_TYPE_KEY, AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES
Instance Attribute Summary
Attributes inherited from Wakame::Action
Instance Method Summary collapse
-
#initialize(svc, do_terminate = true) ⇒ StopService
constructor
A new instance of StopService.
- #on_failed ⇒ Object
- #run ⇒ Object
Methods inherited from Wakame::Action
#acquire_lock, #actor_request, #agent_monitor, #all_subactions_complete?, #flush_subactions, #master, #notes, #notify, #on_canceled, #service_cluster, #status=, #subactions, #sync_actor_request, #trigger_action, #walk_subactions
Methods included from ThreadImmutable
#bind_thread, included, #target_thread, #target_thread?, #thread_check
Methods included from AttributeHelper
#dump_attrs, #retrieve_attr_attribute
Constructor Details
#initialize(svc, do_terminate = true) ⇒ StopService
Returns a new instance of StopService.
4 5 6 7 8 |
# File 'lib/wakame/actions/stop_service.rb', line 4 def initialize(svc, do_terminate=true) raise ArgumentError unless svc.is_a?(Service::ServiceInstance) @svc = svc @do_terminate = do_terminate end |
Instance Method Details
#on_failed ⇒ Object
48 49 50 51 52 |
# File 'lib/wakame/actions/stop_service.rb', line 48 def on_failed StatusDB. { @svc.update_status(Service::STATUS_FAIL) } end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/wakame/actions/stop_service.rb', line 11 def run acquire_lock(@svc.resource.class.to_s) @svc.reload # Skip to act when the service is having below status. if @svc.status == Service::STATUS_TERMINATE && @svc.monitor_status == Service::STATUS_OFFLINE Wakame.log.info("Ignore to stop the service as is being or already OFFLINE: #{@svc.resource.class}") return end StatusDB. { @svc.update_status(Service::STATUS_STOPPING) } trigger_action(NotifyChildChanged.new(@svc)) flush_subactions @svc.reload if @svc.monitor_status == Wakame::Service::STATUS_ONLINE @svc.resource.stop(@svc, self) end if @do_terminate if @svc.resource.require_agent StatusDB. { @svc.update_status(Service::STATUS_QUITTING) } @svc.resource.on_quit_agent(@svc, self) end StatusDB. { @svc.update_status(Service::STATUS_TERMINATE) cluster.destroy(@svc.id) } end end |