X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=bin%2Fmcollectived;fp=bin%2Fmcollectived;h=4f0d1d8f056ccb7cc7667e751308ed3c1402a9d2;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/bin/mcollectived b/bin/mcollectived new file mode 100755 index 0000000..4f0d1d8 --- /dev/null +++ b/bin/mcollectived @@ -0,0 +1,49 @@ +#!/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 + +MCollective::Log.info("The Marionette Collective #{MCollective::VERSION} started logging at #{config.loglevel} level") + +if config.daemonize + MCollective::Log.debug("Starting in the background (#{config.daemonize})") + + if MCollective::Util.windows? + require 'mcollective/windows_daemon' + + MCollective::WindowsDaemon.daemonize_runner + else + require 'mcollective/unix_daemon' + + MCollective::UnixDaemon.daemonize_runner(pid) + end +else + MCollective::Log.debug("Starting in the foreground") + runner = MCollective::Runner.new(configfile) + runner.run +end