3516730a61e4364bd8edab767000089b227f5488
[packages/precise/mcollective.git] / lib / mcollective / windows_daemon.rb
1 require 'win32/daemon'
2
3 module MCollective
4   class WindowsDaemon < Win32::Daemon
5     def self.daemonize_runner(pid=nil)
6       raise "Writing pid files are not supported on the Windows Platform" if pid
7       raise "The Windows Daemonizer should only be used on the Windows Platform" unless Util.windows?
8
9       WindowsDaemon.mainloop
10     end
11
12     def service_main
13       Log.debug("Starting Windows Service Daemon")
14
15       runner = Runner.new(nil)
16       runner.run
17     end
18
19     def service_stop
20       Log.info("Windows service stopping")
21       PluginManager["connector_plugin"].disconnect
22       exit! 0
23     end
24   end
25 end