Beispiel #1
0
def Run():
    import logging
    #logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')
    
    pid = Config.get().core.pid
    spool_dir = Config.get().core.spool
    args = Config.get().optargs
    (pid_dir, name) = os.path.split(pid)
    
    print name.split('.pid')[0]
    print pid_dir
    daemon = Daemon(name=name.split('.pid')[0], pid_dir=pid_dir,
                    stdin=spool_dir,
                    stdout=spool_dir,
                    stderr=spool_dir)
    
    if 'start' in args[0]:
        daemon.start()
        core = Core()
        core.run()
    
    elif 'stop' in args[0]:
        daemon.stop()
        
    elif 'status' in args[0]:
        daemon.status()
    else:
        print 'Wut?'
        print args
def run():
    daemon = Daemon(name, pid_dir, stdin, stdout, stderr)
    daemon.start()

    try:
        start_event_engine()
    except Exception, e:
        print "[ERROR] ",
        print e
Beispiel #3
0
def main(action="foreground"):
    from supay import Daemon
    daemon = Daemon(name="netl2server", catch_all_log=cfg.get("httpd", "logfile"))

    if action ==  "start":
        daemon.start()
        start()
    elif action == "foreground":
        start()
    elif action == "stop":
        daemon.stop()
    elif action == "status":
        daemon.status()
    else:
        cli_help()
Beispiel #4
0
            cmd = Popen(['/etc/init.d/xvp', 'restart'], stdout=PIPE, stderr=PIPE)
            response = cmd.communicate()[0]
            syslog.syslog(response)
        except Exception as e:
            syslog.syslog('Error running XVP Consumer: %s' % e)

def main():
    Worker.run([queue_name], server=config.get('nephelae', 'resque_server'))

if __name__ == '__main__':
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'a:', ['action='])
    except getopt.GetoptError, err:
        print str(err)

    action = 'start'
    for o, a in opts:
        if o in ('-a', '--action'):
            action = a

    daemon = Daemon(name='xvp-agent', catch_all_log='/var/log/xvp-agent.log')
    if action == 'start':
        daemon.start()
        main()
    elif action == 'status':
        daemon.status()
    elif action == 'stop':
        daemon.stop()
    elif action == 'foreground':
        main()