lib/ruboty/robot.rb in ruboty-1.2.4 vs lib/ruboty/robot.rb in ruboty-1.3.0
- old
+ new
@@ -12,13 +12,15 @@
def initialize(options = {})
@options = options
end
def run
+ daemon
dotenv
bundle
setup
+ pid
remember
handle
adapt
end
@@ -67,10 +69,14 @@
def env
ENV["RUBOTY_ENV"] || DEFAULT_ENV
end
memoize :env
+ def daemon
+ Process.daemon(true, false) if options[:daemon]
+ end
+
def dotenv
Dotenv.load if options[:dotenv]
end
def setup
@@ -86,8 +92,16 @@
brain
end
def handle
handlers
+ end
+
+ def pid
+ path = options[:pid]
+ if path
+ File.open(path, "w") { |f| f.write(Process.pid) }
+ at_exit { File.unlink(path) }
+ end
end
end
end