Exemplo n.º 1
0
def main():
    """Parse args and run main daemon function

    :return: None
    """
    parser = optparse.OptionParser(
        "%prog [options]", version="%prog " + VERSION)
    parser.add_option('-c', '--config',
                      dest="config_file", metavar="INI-CONFIG-FILE",
                      help='Config file')
    parser.add_option('-d', '--daemon', action='store_true',
                      dest="is_daemon",
                      help="Run in daemon mode")
    parser.add_option('-r', '--replace', action='store_true',
                      dest="do_replace",
                      help="Replace previous running scheduler")
    parser.add_option('--debugfile', dest='debug_file',
                      help=("Debug file. Default: not used "
                            "(why debug a bug free program? :) )"))
    parser.add_option("-p", "--profile",
                      dest="profile",
                      help="Dump a profile file. Need the python cProfile librairy")

    opts, args = parser.parse_args()
    if args:
        parser.error("Does not accept any argument.")

    daemon = Alignak(debug=opts.debug_file is not None, **opts.__dict__)
    if not opts.profile:
        daemon.main()
    else:
        # For perf running:
        import cProfile
        cProfile.run('''daemon.main()''', opts.profile)
Exemplo n.º 2
0
def main():
    """Parse args and run main daemon function

    :return: None
    """
    args = parse_daemon_args()
    daemon = Alignak(debug=args.debug_file is not None, **args.__dict__)
    daemon.main()
Exemplo n.º 3
0
def main():
    """Parse args and run main daemon function

    :return: None
    """
    try:
        args = parse_daemon_args()
        daemon = Alignak(**args.__dict__)
        daemon.main()
    except Exception as exp:  # pylint: disable=broad-except
        sys.stderr.write("*** Daemon exited because: %s" % str(exp))
        traceback.print_exc()
        exit(1)