Class: SimpleDaemon
- Inherits:
-
Object
- Object
- SimpleDaemon
- Defined in:
- lib/simple_daemon.rb
Constant Summary collapse
- @@config =
OpenStruct.new
Class Method Summary collapse
-
.daemonized(&block) ⇒ Object
Run block as a daemon.
-
.foreground(&block) ⇒ Object
Run block in the foreground.
- .setup {|@@config| ... } ⇒ Object
Class Method Details
.daemonized(&block) ⇒ Object
Run block as a daemon
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/simple_daemon.rb', line 34 def daemonized(&block) self.set_prerun_config_defaults self.set_process_name self.drop_privileges self.daemonize self.chroot self.clean_fd self.redirect_io yield end |
.foreground(&block) ⇒ Object
Run block in the foreground
23 24 25 26 27 28 29 30 31 |
# File 'lib/simple_daemon.rb', line 23 def foreground(&block) self.set_prerun_config_defaults self.set_process_name self.chroot self.clean_fd self.redirect_io(true) yield end |
.setup {|@@config| ... } ⇒ Object
18 19 20 |
# File 'lib/simple_daemon.rb', line 18 def setup(&block) yield @@config end |