# Check config file SERVER_CONFIG = '/etc/domoweb.cfg' if not os.path.isfile(SERVER_CONFIG): sys.stderr.write("Error: Can't find the file '%s'\n" % SERVER_CONFIG) sys.exit(1) options.define("sqlite_db", default="/var/lib/domoweb/db.sqlite", help="Database file path", type=str) options.define("port", default=40404, help="Launch on the given port", type=int) options.define("debut", default=False, help="Debug mode", type=bool) options.parse_config_file("/etc/domoweb.cfg") logger.info("Running from : %s" % domoweb.PROJECTPATH) packLoader.loadWidgets(domoweb.PACKSPATH) packLoader.loadIconsets(domoweb.PACKSPATH) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds')) logger.info("Creating : %s" % os.path.join(domoweb.VARPATH, 'backgrounds')) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')) mqDataLoader.loadDatatypes() mqDataLoader.loadDevices() logger.info("Starting tornado web server") application.listen(options.port) logger.info("Starting MQ Handler") MQHandler() ioloop.IOLoop.instance().start()
options.define("ssl_key", default="ssl_key.pem", help="SSL key file path", type=str) options.parse_config_file(SERVER_CONFIG) logger.info("Running from : %s" % domoweb.PROJECTPATH) packLoader.loadWidgets(domoweb.PACKSPATH, options.develop) packLoader.loadThemes(domoweb.PACKSPATH, options.develop) # TODO #packLoader.loadIcons(domoweb.PACKSPATH, options.develop) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds')) logger.info("Creating : %s" % os.path.join(domoweb.VARPATH, 'backgrounds')) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')) mqDataLoader.loadDatatypes(options.develop) mqDataLoader.loadDevices(options.develop) logger.info("Starting tornado web server") # https if options.use_ssl: logger.info("SSL activated") logger.info("SSL certificate file : {0}".format(options.ssl_certificate)) logger.info("SSL certificate file : {0}".format(options.ssl_key)) http_server_ssl = tornado.httpserver.HTTPServer(application, ssl_options = { "certfile": os.path.join(options.ssl_certificate), "keyfile": os.path.join(options.ssl_key) }) logger.info("Start https server on port '{0}'".format(options.ssl_port)) http_server_ssl.listen(options.ssl_port)
logger.info("Running from : %s" % domoweb.PROJECTPATH) packLoader.loadWidgets(domoweb.PACKSPATH, options.develop) packLoader.loadThemes(domoweb.PACKSPATH, options.develop) # TODO #packLoader.loadIcons(domoweb.PACKSPATH, options.develop) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds')) logger.info("Creating : %s" % os.path.join(domoweb.VARPATH, 'backgrounds')) if not os.path.isdir( os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')) mqDataLoader.loadDatatypes(options.develop) mqDataLoader.loadDevices(options.develop) logger.info("Starting tornado web server") # https if options.use_ssl: logger.info("SSL activated") logger.info("SSL certificate file : {0}".format( options.ssl_certificate)) logger.info("SSL certificate file : {0}".format(options.ssl_key)) http_server_ssl = tornado.httpserver.HTTPServer( application, ssl_options={ "certfile": os.path.join(options.ssl_certificate), "keyfile": os.path.join(options.ssl_key) })