lib/writefully/cli.rb in writefully-0.4.0 vs lib/writefully/cli.rb in writefully-0.4.1

- old
+ new

@@ -7,27 +7,27 @@ method_options %w( daemonize -d ) => :boolean def start(file) config = Writefully.config_from(file) - + if options.daemonize? - Process.daemon(true, true) - pid = waitpid(spawn(listen(config))) - write pid, config[:pidfile] + ::Process.daemon(true, true) + write(::Process.pid, config[:pidfile]) + spawn(listen(config)) else - Signal.trap("INT") { $stdout.puts "Writefully exiting..."; exit } + ::Signal.trap("INT") { $stdout.puts "Writefully exiting..."; exit } listen(config) end end desc "stop", "Stop listening for content directory changes" def stop(file) config = Writefully.config_from(file) pid = open(config[:pidfile]).read.strip.to_i - Process.kill("HUP", pid) + ::Process.kill("HUP", pid) true rescue Errno::ENOENT $stdout.puts "#{pidfile} does not exist: Errno::ENOENT" true rescue Errno::ESRCH @@ -50,10 +50,10 @@ File.open pidfile, "w" do |f| f.write pid end rescue ::Exception => e $stderr.puts "While writing the PID to file, unexpected #{e.class}: #{e}" - Process.kill "HUP", pid + ::Process.kill "HUP", pid end end end end