Fix : fix hot module under windows test. (at leat I hope...)
[shinken.git] / bin / shinken-receiver
blobc72967981fe877fc18d1b9826d28dc14b828d81d
1 #!/usr/bin/env python
2 #Copyright (C) 2009-2011 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
5 # Gregory Starck, g.starck@gmail.com
6 # Hartmut Goebel, h.goebel@goebel-consult.de
8 #This file is part of Shinken.
10 #Shinken is free software: you can redistribute it and/or modify
11 #it under the terms of the GNU Affero General Public License as published by
12 #the Free Software Foundation, either version 3 of the License, or
13 #(at your option) any later version.
15 #Shinken is distributed in the hope that it will be useful,
16 #but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 #GNU Affero General Public License for more details.
20 #You should have received a copy of the GNU Affero General Public License
21 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
24 #This class is an interface for the Receiver
25 #The receiver listens to the Arbiter for the configuration sent through
26 #the port given as first argument.
27 #The configuration sent by the arbiter specifies on which schedulers
28 #the receiver will take broks.
29 #When the receiver is already launched and has its own conf, it still
30 #listens to arbiter (one a timeout)
31 #In case the arbiter has a new conf to send, the receiver forget his old
32 #schedulers (and their associated broks) and take the new ones instead.
35 import os
36 import sys
37 import optparse
39 try:
40 import shinken
41 except ImportError:
42 # If importing shinken fails, try to load from current directory
43 # or parent directory to support running without installation.
44 # Submodules will then be loaded from there, too.
45 import imp
46 if not hasattr(os, "getuid") or os.getuid() != 0:
47 imp.load_module('shinken', *imp.find_module('shinken', [".", ".."]))
49 from shinken.daemons.receiverdaemon import Receiver
50 from shinken.bin import VERSION
52 parser = optparse.OptionParser(
53 "%prog [options]", version="%prog " + VERSION)
54 parser.add_option('-c', '--config',
55 dest="config_file", metavar="CONFIG-FILE",
56 help='Config file')
57 parser.add_option('-d', '--daemon', action='store_true',
58 dest="is_daemon",
59 help="Run in daemon mode")
60 parser.add_option('-r', '--replace', action='store_true',
61 dest="do_replace",
62 help="Replace previous running receiver")
63 parser.add_option('--debugfile', dest='debug_file',
64 help=("Debug file. Default: not used "
65 "(why debug a bug free program? :) )"))
66 opts, args = parser.parse_args()
67 if args:
68 parser.error("Does not accept any argument.")
70 daemon = Receiver(debug=opts.debug_file is not None, **opts.__dict__)
71 daemon.main()