Sha256: 55bc0ded8b3704dd6b0126c4af3df309b86d1429eec0670ca97e229340993f46
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
class Ginst::WebServer require('daemons') def self.start execute('start') end def self.restart execute('restart') end def self.stop execute('stop') end def self.status execute('status') end def self.run execute('run') end private def self.execute(command) script = Ginst.root+'/script/server' if command == 'status' capture_output do Daemons.run(script, generate_options_for_command(command)) end else pid = fork do Daemons.run(script, generate_options_for_command(command)) exit(0) end Process.waitpid2(pid) status end end def self.capture_output $stdout, $stderr = StringIO.new, StringIO.new yield $stdout.string + $stderr.string ensure $stdout = STDOUT $stderr = STDERR end def self.generate_options_for_command(command) options = { :app_name => 'ginst', :dir_mode => :normal, :dir => File.expand_path((Ginst.data_dir || ENV['GINST_DIR'])+'/tmp'), :monitor => false, :mode => :exec, :log_output => true, :ARGV => [command] } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ginst-2.0.1 | lib/ginst/web_server.rb |
ginst-2.0.0 | lib/ginst/web_server.rb |