Class: CPEE::Properties::PutState
- Inherits:
-
Riddl::Implementation
- Object
- Riddl::Implementation
- CPEE::Properties::PutState
- Defined in:
- lib/cpee/implementation_properties.rb
Overview
}}}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run(id, opts, state) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/cpee/implementation_properties.rb', line 213 def self::run(id,opts,state) exe = File.join(opts[:instances],id.to_s,File.basename(opts[:backend_run])) case state when 'running' CPEE::Persistence::write_instance id, opts pid = Kernel.spawn(exe , :pgroup => true, :in => '/dev/null', :out => exe + '.out', :err => exe + '.err') Process.detach pid File.write(exe + '.pid',pid) when 'stopping' pid = File.read(exe + '.pid') rescue nil if pid && (Process.kill(0, pid.to_i) rescue false) Process.kill('HUP', pid.to_i) rescue nil else File.unlink(exe + '.pid') rescue nil PutState::set id, opts, 'stopped' end else ### Most probably this is never needed. Lets see. PutState::set id, opts, state end end |
.set(id, opts, state) ⇒ Object
{{{
209 210 211 |
# File 'lib/cpee/implementation_properties.rb', line 209 def self::set(id,opts,state) CPEE::Persistence::set_item(id,opts,'state',:state => state, :timestamp => Time.now.xmlschema(3)) end |