if HAVE_SYSTEMD
systemdsystemunit_DATA = \
src/systemd/pakfire-hub-1.service \
- src/systemd/pakfire-hub-2.service
+ src/systemd/pakfire-hub-2.service \
+ src/systemd/pakfire-web-1.service \
+ src/systemd/pakfire-web-2.service
CLEANFILES += \
$(systemdsystemunit_DATA)
EXTRA_DIST += \
src/systemd/pakfire-hub-1.service.in \
- src/systemd/pakfire-hub-2.service.in
+ src/systemd/pakfire-hub-2.service.in \
+ src/systemd/pakfire-web-1.service.in \
+ src/systemd/pakfire-web-2.service.in
dist_database_DATA = \
src/database.sql
#!/usr/bin/python
-import daemon
-import os
-import signal
-import sys
-
+import tornado.ioloop
import tornado.options
-from pakfire.buildservice.web import Application
-
-#tornado.options.parse_command_line()
+import pakfire.buildservice.web
-if __name__ == "__main__":
- app = Application()
+tornado.options.define("debug", type=bool, default=False, help="Enable debug mode")
+tornado.options.define("port", type=int, default=9000, help="Port to listen on")
- context = daemon.DaemonContext(
- working_directory=os.getcwd(),
-# stdout=sys.stdout, stderr=sys.stderr, # XXX causes errors...
- )
+def run():
+ tornado.options.parse_command_line()
- context.signal_map = {
- signal.SIGHUP : app.reload,
- signal.SIGTERM : app.shutdown,
- }
+ # Initialise application
+ app = pakfire.buildservice.web.Application(debug=tornado.options.options.debug)
+ app.listen(tornado.options.options.port, xheaders=True)
-# with context:
-# app.run()
+ # Launch IOLoop
+ tornado.ioloop.IOLoop.current().start()
- app.run()
+run()
# encoding: utf-8
import logging
-import multiprocessing
-import os.path
-import tornado.httpserver
import tornado.locale
-import tornado.options
import tornado.web
from .. import Backend
from ..constants import *
-from ..decorators import *
# Import all handlers
from . import api
from . import ui_modules
-# Enable logging
-tornado.options.define("debug", default=False, help="Run in debug mode", type=bool)
-tornado.options.parse_command_line()
-
class Application(tornado.web.Application):
- def __init__(self, **_settings):
+ def __init__(self, **kwargs):
settings = dict(
- debug = tornado.options.options.debug,
- gzip = True,
login_url = "/login",
template_path = TEMPLATESDIR,
static_path = STATICDIR,
},
xsrf_cookies = True,
)
- settings.update(_settings)
+ settings.update(kwargs)
# Load translations.
tornado.locale.load_gettext_translations(LOCALEDIR, PACKAGE_NAME)
(r"/api/packages/autocomplete", api.ApiPackagesAutocomplete),
], default_handler_class=errors.Error404Handler, **settings)
- logging.info("Successfully initialied application")
-
- @lazy_property
- def backend(self):
- """
- Backend connection
- """
- return Backend()
-
- def __del__(self):
- logging.info("Shutting down application")
-
- @property
- def ioloop(self):
- return tornado.ioloop.IOLoop.instance()
-
- def shutdown(self, *args):
- logging.debug("Caught shutdown signal")
- self.ioloop.stop()
-
- def run(self, port=7001):
- logging.debug("Going to background")
+ # Launch backend
+ self.backend = Backend()
- http_server = tornado.httpserver.HTTPServer(self, xheaders=True)
-
- # If we are not running in debug mode, we can actually run multiple
- # frontends to get best performance out of our service.
- if self.settings.get("debug", False):
- http_server.listen(port)
- else:
- cpu_count = multiprocessing.cpu_count()
-
- http_server.bind(port)
- http_server.start(num_processes=cpu_count)
-
- # All requests should be done after 60 seconds or they will be killed.
- self.ioloop.set_blocking_log_threshold(60)
-
- self.ioloop.start()
-
- def reload(self):
- logging.debug("Caught reload signal")
+ logging.info("Successfully initialied application")
## UI methods