Пример #1
0
def run():
    import cleanup
    import motionctl
    import motioneye
    import smbctl
    import thumbnailer
    import tornado.ioloop

    configure_signals()
    logging.info('hello! this is motionEye server %s' % motioneye.VERSION)

    test_requirements()

    if settings.SMB_SHARES:

        stop, start = smbctl.update_mounts()  # @UnusedVariable
        if start:
            start_motion()

    else:
        start_motion()

    start_cleanup()
    start_wsswitch()

    if settings.THUMBNAILER_INTERVAL:
        start_thumbnailer()

    template.add_context('static_path', settings.BASE_PATH + '/static/')
    
    application = Application(handler_mapping, debug=False, log_function=_log_request,
            static_path=settings.STATIC_PATH, static_url_prefix='/static/')
    
    application.listen(settings.PORT, settings.LISTEN)
    logging.info('server started')
    
    tornado.ioloop.IOLoop.instance().start()

    logging.info('server stopped')
    
    if thumbnailer.running():
        thumbnailer.stop()
        logging.info('thumbnailer stopped')

    if cleanup.running():
        cleanup.stop()
        logging.info('cleanup stopped')

    if motionctl.running():
        motionctl.stop()
        logging.info('motion stopped')
    
    if settings.SMB_SHARES:
        smbctl.umount_all()
        logging.info('SMB shares unmounted')

    logging.info('bye!')
Пример #2
0
def run():
    import cleanup
    import mjpgclient
    import motionctl
    import motioneye
    import smbctl
    import tasks
    import wsswitch

    configure_signals()
    logging.info('hello! this is motionEye server %s' % motioneye.VERSION)

    test_requirements()
    make_media_folders()

    if settings.SMB_SHARES:
        stop, start = smbctl.update_mounts()  # @UnusedVariable
        if start:
            start_motion()

    else:
        start_motion()

    if settings.CLEANUP_INTERVAL:
        cleanup.start()
        logging.info('cleanup started')

    wsswitch.start()
    logging.info('wsswitch started')

    tasks.start()
    logging.info('tasks started')

    if settings.MJPG_CLIENT_TIMEOUT:
        mjpgclient.start()
        logging.info('mjpg client garbage collector started')

    if settings.SMB_SHARES:
        smbctl.start()
        logging.info('smb mounts started')

    template.add_context('static_path', settings.BASE_PATH + '/static/')

    application = Application(handler_mapping,
                              debug=False,
                              log_function=_log_request,
                              static_path=settings.STATIC_PATH,
                              static_url_prefix='/static/')

    application.listen(settings.PORT, settings.LISTEN)
    logging.info('server started')

    io_loop = IOLoop.instance()
    io_loop.start()

    logging.info('server stopped')

    tasks.stop()
    logging.info('tasks stopped')

    if cleanup.running():
        cleanup.stop()
        logging.info('cleanup stopped')

    if motionctl.running():
        motionctl.stop()
        logging.info('motion stopped')

    if settings.SMB_SHARES:
        smbctl.stop()
        logging.info('smb mounts stopped')

    logging.info('bye!')
Пример #3
0
def run():
    import cleanup
    import mjpgclient
    import motionctl
    import motioneye
    import smbctl
    import thumbnailer
    import wsswitch

    configure_signals()
    logging.info('hello! this is motionEye server %s' % motioneye.VERSION)

    test_requirements()

    if settings.SMB_SHARES:
        stop, start = smbctl.update_mounts()  # @UnusedVariable
        if start:
            start_motion()

    else:
        start_motion()

    if settings.CLEANUP_INTERVAL:
        cleanup.start()
        logging.info('cleanup started')
        
    wsswitch.start()
    logging.info('wsswitch started')

    if settings.THUMBNAILER_INTERVAL:
        thumbnailer.start()
        logging.info('thumbnailer started')

    if settings.MJPG_CLIENT_TIMEOUT:
        mjpgclient.start()
        logging.info('mjpg client garbage collector started')

    if settings.SMB_SHARES:
        smbctl.start()
        logging.info('smb mounts started')

    template.add_context('static_path', settings.BASE_PATH + '/static/')
    
    application = Application(handler_mapping, debug=False, log_function=_log_request,
            static_path=settings.STATIC_PATH, static_url_prefix='/static/')
    
    application.listen(settings.PORT, settings.LISTEN)
    logging.info('server started')
    
    IOLoop.instance().start()

    logging.info('server stopped')
    
    if thumbnailer.running():
        thumbnailer.stop()
        logging.info('thumbnailer stopped')

    if cleanup.running():
        cleanup.stop()
        logging.info('cleanup stopped')

    if motionctl.running():
        motionctl.stop()
        logging.info('motion stopped')
    
    if settings.SMB_SHARES:
        smbctl.stop()
        logging.info('smb mounts stopped')

    logging.info('bye!')
Пример #4
0
        (r'^/movie/(?P<camera_id>\d+)/(?P<op>delete_all)/(?P<group>.+?)/?$', handlers.MovieHandler),
        (r'^/_relay_event/?$', handlers.RelayEventHandler),
        (r'^/log/(?P<name>\w+)/?$', handlers.LogHandler),
        (r'^/update/?$', handlers.UpdateHandler),
        (r'^/power/(?P<op>shutdown|reboot)/?$', handlers.PowerHandler),
        (r'^/version/?$', handlers.VersionHandler),
        (r'^/login/?$', handlers.LoginHandler),
        (r'^.*$', handlers.NotFoundHandler),
    ],
    debug=False,
    log_function=_log_request,
    static_path=settings.STATIC_PATH,
    static_url_prefix=settings.STATIC_URL
)

template.add_context('STATIC_URL', settings.STATIC_URL)


def configure_signals():
    def bye_handler(signal, frame):
        import tornado.ioloop
        
        logging.info('interrupt signal received, shutting down...')

        # shut down the IO loop if it has been started
        ioloop = tornado.ioloop.IOLoop.instance()
        ioloop.stop()
        
    def child_handler(signal, frame):
        # this is required for the multiprocessing mechanism to work
        multiprocessing.active_children()
Пример #5
0
    (r'^/api/(?P<camera_id>\d+)/(?P<api_key>\d+)/(?P<op>enable|disable)/?$',
     handlers.ApiHandler),
    (r'^/config/(?P<camera_id>\d+)/(?P<op>get|set|rem|set_preview|enable|disable)/?$',
     handlers.ConfigHandler),
    (r'^/config/(?P<op>add|list|backup|restore)/?$', handlers.ConfigHandler),
    (r'^/picture/(?P<camera_id>\d+)/(?P<op>current|list|frame)/?$',
     handlers.PictureHandler),
    (r'^/picture/(?P<camera_id>\d+)/(?P<op>download|preview|delete)/(?P<filename>.+?)/?$',
     handlers.PictureHandler),
    (r'^/picture/(?P<camera_id>\d+)/(?P<op>zipped|timelapse|delete_all)/(?P<group>.+?)/?$',
     handlers.PictureHandler),
    (r'^/movie/(?P<camera_id>\d+)/(?P<op>list)/?$', handlers.MovieHandler),
    (r'^/movie/(?P<camera_id>\d+)/(?P<op>download|preview|delete)/(?P<filename>.+?)/?$',
     handlers.MovieHandler),
    (r'^/movie/(?P<camera_id>\d+)/(?P<op>delete_all)/(?P<group>.+?)/?$',
     handlers.MovieHandler),
    (r'^/_relay_event/?$', handlers.RelayEventHandler),
    (r'^/log/(?P<name>\w+)/?$', handlers.LogHandler),
    (r'^/update/?$', handlers.UpdateHandler),
    (r'^/power/(?P<op>shutdown|reboot)/?$', handlers.PowerHandler),
    (r'^/version/?$', handlers.VersionHandler),
    (r'^/login/?$', handlers.LoginHandler),
    (r'^.*$', handlers.NotFoundHandler),
],
                          debug=False,
                          log_function=log_request,
                          static_path=settings.STATIC_PATH,
                          static_url_prefix=settings.STATIC_URL)

template.add_context('STATIC_URL', settings.STATIC_URL)
Пример #6
0
def run():
    import cleanup
    import mjpgclient
    import motionctl
    import motioneye
    import smbctl
    import tasks
    import wsswitch

    configure_signals()
    logging.info('hello! this is motionEye server %s' % motioneye.VERSION)

    test_requirements()
    make_media_folders()

    if settings.SMB_SHARES:
        stop, start = smbctl.update_mounts()  # @UnusedVariable
        if start:
            start_motion()

    else:
        start_motion()

    if settings.CLEANUP_INTERVAL:
        cleanup.start()
        logging.info('cleanup started')

    wsswitch.start()
    logging.info('wsswitch started')

    tasks.start()
    logging.info('tasks started')

    if settings.MJPG_CLIENT_TIMEOUT:
        mjpgclient.start()
        logging.info('mjpg client garbage collector started')

    if settings.SMB_SHARES:
        smbctl.start()
        logging.info('smb mounts started')

    template.add_context('static_path', 'static/')

    application = Application(handler_mapping,
                              debug=False,
                              log_function=_log_request,
                              static_path=settings.STATIC_PATH,
                              static_url_prefix='/static/')

    if settings.SSL_PORT > 0:
        application.listen(settings.SSL_PORT,
                           settings.LISTEN,
                           ssl_options={
                               "certfile": settings.SSL_CERT,
                               "keyfile": settings.SSL_KEY,
                           })
        logging.info('https server started on port: %s' % settings.SSL_PORT)

    application.listen(settings.PORT, settings.LISTEN)
    logging.info('http server started ono port: %s' % settings.PORT)

    io_loop = IOLoop.instance()
    # we need to reset the loop's PID to fix PID checks when running in daemon mode
    io_loop._pid = os.getpid()
    io_loop.start()

    logging.info('server stopped')

    tasks.stop()
    logging.info('tasks stopped')

    if cleanup.running():
        cleanup.stop()
        logging.info('cleanup stopped')

    if motionctl.running():
        motionctl.stop()
        logging.info('motion stopped')

    if settings.SMB_SHARES:
        smbctl.stop()
        logging.info('smb mounts stopped')

    logging.info('bye!')
Пример #7
0
def run():
    import cleanup
    import motionctl
    import motioneye
    import smbctl
    import thumbnailer
    import tornado.ioloop

    configure_signals()
    logging.info("hello! this is motionEye server %s" % motioneye.VERSION)

    test_requirements()

    if settings.SMB_SHARES:

        stop, start = smbctl.update_mounts()  # @UnusedVariable
        if start:
            start_motion()

    else:
        start_motion()

    start_cleanup()
    start_wsswitch()

    if settings.THUMBNAILER_INTERVAL:
        start_thumbnailer()

    template.add_context("static_path", settings.BASE_PATH + "/static/")

    application = Application(
        handler_mapping,
        debug=False,
        log_function=_log_request,
        static_path=settings.STATIC_PATH,
        static_url_prefix="/static/",
    )

    application.listen(settings.PORT, settings.LISTEN)
    logging.info("server started")

    tornado.ioloop.IOLoop.instance().start()

    logging.info("server stopped")

    if thumbnailer.running():
        thumbnailer.stop()
        logging.info("thumbnailer stopped")

    if cleanup.running():
        cleanup.stop()
        logging.info("cleanup stopped")

    if motionctl.running():
        motionctl.stop()
        logging.info("motion stopped")

    if settings.SMB_SHARES:
        smbctl.umount_all()
        logging.info("SMB shares unmounted")

    logging.info("bye!")