Class: ProcessWanker::UpstartService

Inherits:
Service
  • Object
show all
Includes:
Log
Defined in:
lib/service_classes/upstart_service.rb

Constant Summary

Constants included from Log

Log::DEBUG, Log::ERROR, Log::INFO, Log::WARN

Instance Attribute Summary

Attributes inherited from Service

#attempt_count, #config_node, #current_state, #dependencies, #ignore, #last_action_time, #last_fail_time, #last_transition_time, #params, #prev_state, #show_state, #stable, #suppress, #want_state, #want_state_mode

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Log

debug, error, info, log, set_level, warn

Methods inherited from Service

#check_action_delay, #extract_params, #group_name, #matches_single, #matches_spec, #name, #resolve_dependencies, #safe_do, #safe_do_ping, #safe_do_start, #safe_do_stop, #set_want_state, #tick, #validate_params

Constructor Details

#initialize(iparams) ⇒ UpstartService

Returns a new instance of UpstartService.



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/service_classes/upstart_service.rb', line 42

def initialize(iparams)
		
# extract parameters
extract_params(
	iparams,
	[
		:job_name,
	])

@job_name=@params[:job_name] || iparams[:name]

super(iparams)
end

Class Method Details

.nice_nameObject



32
33
34
# File 'lib/service_classes/upstart_service.rb', line 32

def self.nice_name
	"upstart_service"
end

Instance Method Details

#do_pingObject

ping

return run state of process



85
86
87
88
# File 'lib/service_classes/upstart_service.rb', line 85

def do_ping
status=`initctl status #{@job_name}`
status.include?("running") ? :up : :down
end

#do_start(attempt_count) ⇒ Object

start



62
63
64
65
# File 'lib/service_classes/upstart_service.rb', line 62

def do_start(attempt_count)
	debug("do_start #{self.name}")
system("initctl start #{@job_name}")
end

#do_stop(attempt_count) ⇒ Object

stop



73
74
75
# File 'lib/service_classes/upstart_service.rb', line 73

def do_stop(attempt_count)
system("initctl stop #{@job_name}")
end