def main():
    try:
        CONF(project='myhvac_service')
    except cfg.RequiredOptError as e:
        print '\n\n********************* WOW SOMETHING WENT WRONG!!!! **************************\n'
        print e
        print '\n*****************************************************************************\n\n'
        print 'Configuration Help and Usage:'
        CONF.print_help()
        raise SystemExit(1)

    log.init_log()
    display.init_display()

    LOG.info('Starting up system... pid: %s', os.getpid())
    display.write('Starting up system..')

    db.init_db()
    hvac.init_gpio()

    prog_man = pm.ProgramManager()

    try:
        threads.append(hub.spawn(wsgi.run))
        threads.append(hub.spawn(prog_man.start))

        # Keep main thread alive to capture kill events
        while True:
            hub.sleep(.1)
    except (KeyboardInterrupt, SystemExit):
        LOG.error('Caught KeyboardInterrupt, initiate shutdown')
    finally:
        shutdown(prog_man)
Exemple #2
0
def main():
    try:
        CONF(project='myhvac_service')
    except cfg.RequiredOptError as e:
        print '\n\n********************* WOW SOMETHING WENT WRONG!!!! **************************\n'
        print e
        print '\n*****************************************************************************\n\n'
        print 'Configuration Help and Usage:'
        CONF.print_help()
        raise SystemExit(1)

    log.init_log()
    display.init_display()

    LOG.info('Starting up system... pid: %s', os.getpid())
    display.write('Starting up system..')

    db.init_db()
    hvac.init_gpio()

    prog_man = pm.ProgramManager()

    try:
        threads.append(hub.spawn(wsgi.run))
        threads.append(hub.spawn(prog_man.start))

        # Keep main thread alive to capture kill events
        while True:
            hub.sleep(.1)
    except (KeyboardInterrupt, SystemExit):
        LOG.error('Caught KeyboardInterrupt, initiate shutdown')
    finally:
        shutdown(prog_man)
def shutdown(prog_man):
    display.write('Shutting down...')
    LOG.info('Shutting down system...')
    wsgi.stop()
    prog_man.close()

    # Wait for all threads to shut down
    hub.joinall(threads)
    display.clear()
Exemple #4
0
def shutdown(prog_man):
    display.write('Shutting down...')
    LOG.info('Shutting down system...')
    wsgi.stop()
    prog_man.close()

    # Wait for all threads to shut down
    hub.joinall(threads)
    display.clear()