forked from choria-legacy/marionette-collective
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcollectived.rb
executable file
·59 lines (47 loc) · 1.38 KB
/
mcollectived.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env ruby
require 'mcollective'
require 'getoptlong'
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT],
[ '--pidfile', '-p', GetoptLong::REQUIRED_ARGUMENT]
)
configfile = "/etc/mcollective/server.cfg"
pid = ""
opts.each do |opt, arg|
case opt
when '--help'
puts "Usage: mcollectived.rb [--config /path/to/config] [--pidfile /path/to/pid]"
exit
when '--config'
configfile = arg
when '--pidfile'
pid = arg
end
end
config = MCollective::Config.instance
config.loadconfig(configfile) unless config.configured
log = MCollective::Log.instance
log.info("The Marionette Collective #{MCollective::VERSION} started logging at #{config.loglevel} level")
Signal.trap("TERM") do
log.info("Received TERM signal, terminating")
exit!
end
if config.daemonize
log.debug("Starting in the background (#{config.daemonize})")
MCollective::Runner.daemonize do
if pid
begin
File.open(pid, 'w') {|f| f.write(Process.pid) }
rescue Exception => e
end
end
runner = MCollective::Runner.new(configfile)
runner.run
end
else
log.debug("Starting in the foreground")
runner = MCollective::Runner.new(configfile)
runner.run
end
# vi:tabstop=4:expandtab:ai