示例#1
0
    def start_services(self):
        # HTTPS server
        sockets = tornado.netutil.bind_sockets(self.port, address=Settings['main_app']['servername'])
        redir_sockets = tornado.netutil.bind_sockets(self.redir_port, address=Settings['main_app']['servername'])

        # Start the mail, git, reviewboard and XMPP queue handlers
        worker_pids = []
        worker_pids.extend(MailQueue.start_worker())
        worker_pids.extend(RBQueue.start_worker())
        worker_pids.extend(XMPPQueue.start_worker())
        worker_pids.extend(GitQueue.start_worker())
        for worker_pid in worker_pids:
            pid.write(self.pid_file, append=True, pid=worker_pid)
        self.queue_worker_pids.extend(worker_pids)

        tornado.process.fork_processes(Settings['tornado']['num_workers'])

        server = tornado.httpserver.HTTPServer(self.main_app, ssl_options={
                'certfile': Settings['main_app']['ssl_certfile'],
                # This really should be read into a string so we can drop privileges
                # after reading the key but before starting the server, but Python
                # doesn't let us use strings for keys until Python 3.2 :(
                'keyfile': Settings['main_app']['ssl_keyfile'],
                })
        server.add_sockets(sockets)

        # HTTP server (to redirect to HTTPS)
        redir_server = tornado.httpserver.HTTPServer(self.redir_app)
        redir_server.add_sockets(redir_sockets)
示例#2
0
    def start_services(self):
        # HTTPS server
        sockets = tornado.netutil.bind_sockets(
            self.port, address=Settings['main_app']['servername'])
        redir_sockets = tornado.netutil.bind_sockets(
            self.redir_port, address=Settings['main_app']['servername'])

        # Start the mail, git, reviewboard and XMPP queue handlers
        worker_pids = []
        worker_pids.extend(MailQueue.start_worker())
        worker_pids.extend(RBQueue.start_worker())
        worker_pids.extend(XMPPQueue.start_worker())
        worker_pids.extend(GitQueue.start_worker())
        for worker_pid in worker_pids:
            pid.write(self.pid_file, append=True, pid=worker_pid)
        self.queue_worker_pids.extend(worker_pids)

        tornado.process.fork_processes(Settings['tornado']['num_workers'])

        server = tornado.httpserver.HTTPServer(
            self.main_app,
            ssl_options={
                'certfile': Settings['main_app']['ssl_certfile'],
                # This really should be read into a string so we can drop privileges
                # after reading the key but before starting the server, but Python
                # doesn't let us use strings for keys until Python 3.2 :(
                'keyfile': Settings['main_app']['ssl_keyfile'],
            })
        server.add_sockets(sockets)

        # HTTP server (to redirect to HTTPS)
        redir_server = tornado.httpserver.HTTPServer(self.redir_app)
        redir_server.add_sockets(redir_sockets)
示例#3
0
    def run(self):
        daemon_context = daemon.DaemonContext(stdout=self.log, stderr=self.log, working_directory=os.getcwd())
        with daemon_context:
            pid.write(self.pid_file, append=True)
            try:
                self.start_services()
                pid.write(self.pid_file, append=True)

                # Drop privileges
                uid = pwd.getpwnam(Settings.get("username", "www-data"))[2]
                os.setuid(uid)

                tornado.ioloop.IOLoop.instance().start()
            finally:
                pid.remove(self.pid_file)
示例#4
0
    def run(self):
        daemon_context = daemon.DaemonContext(stdout=self.log,
                                              stderr=self.log,
                                              working_directory=os.getcwd())
        with daemon_context:
            pid.write(self.pid_file)
            try:
                self.start_services()
                pid.write(self.pid_file, append=True)

                # Drop privileges
                uid = pwd.getpwnam(Settings.get("username", "www-data"))[2]
                os.setuid(uid)

                tornado.ioloop.IOLoop.instance().start()
            finally:
                pid.remove(self.pid_file)