class Twigg::Command::App
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/twigg-app/command/app.rb, line 4 def initialize(*args) super @daemon = @args.delete('-D') || @args.delete('--daemon') @pidfile = consume_option(%w[-P --pidfile], @args) @pidfile_path = File.expand_path(@pidfile) if @pidfile ignore @args end
Public Instance Methods
run()
click to toggle source
# File lib/twigg-app/command/app.rb, line 12 def run stderr 'Daemonizing...' if @daemon if @pidfile_path stderr "Will write to pidfile #{@pidfile}" die 'Pidfile already exists' if File.exist?(@pidfile_path) end Process.daemon if @daemon if @pidfile_path flags = File::WRONLY | File::CREAT | File::EXCL File.open(@pidfile_path, flags) { |f| f.write Process.pid } at_exit { File.unlink(@pidfile_path) } end ::Twigg::App::Server.run! end