Exemple #1
0
    def command_start(self, daemonize=False):
        '''
        Start a server::

            ./manage.py flup:start [--daemonize]
        '''
        if daemonize:
            safe_makedirs(self.logfile, self.pidfile)
        flup_fastcgi(self.app, bind=self.bind, pidfile=self.pidfile,
                     logfile=self.logfile, daemonize=daemonize,
                     cwd=self.cwd, umask=self.umask, **self.fastcgi_params)
Exemple #2
0
    def test_safe_makedirs(self):
        tmp = tempfile.mkdtemp()
        dir_path = os.path.join(tmp, 'aa', 'bb')
        file_path = os.path.join(dir_path, 'file.ext')
        safe_makedirs(file_path)
        self.assertTrue(os.path.isdir(dir_path))
        # Must not fail when is alreay exists
        safe_makedirs(file_path)

        # Cleaning up
        shutil.rmtree(tmp)
Exemple #3
0
    def test_safe_makedirs(self):
        tmp = tempfile.mkdtemp()
        dir_path = os.path.join(tmp, 'aa', 'bb')
        file_path = os.path.join(dir_path, 'file.ext')
        safe_makedirs(file_path)
        self.assertTrue(os.path.isdir(dir_path))
        # Must not fail when is alreay exists
        safe_makedirs(file_path)

        # Cleaning up
        shutil.rmtree(tmp)
Exemple #4
0
 def __init__(self, app, bind="", logfile=None, pidfile=None, cwd=".", umask=2, fastcgi_params=None):
     self.app = app
     self.cwd = os.path.abspath(cwd)
     if ":" in bind:
         host, port = bind.split(":")
         port = int(port)
         bind = (host, port)
     else:
         bind = os.path.abspath(bind or os.path.join(self.cwd, "fcgi.sock"))
         safe_makedirs(bind)
     self.bind = bind
     self.umask = umask
     self.logfile = logfile or os.path.join(self.cwd, "fcgi.log")
     self.pidfile = pidfile or os.path.join(self.cwd, "fcgi.pid")
     self.fastcgi_params = fastcgi_params or {}
Exemple #5
0
 def __init__(self, app, bind='', logfile=None, pidfile=None,
              cwd='.', umask=2, fastcgi_params=None):
     self.app = app
     self.cwd = os.path.abspath(cwd)
     if ':' in bind:
         host, port = bind.split(':')
         port = int(port)
     else:
         bind = os.path.abspath(bind or os.path.join(self.cwd, 'fcgi.sock'))
         safe_makedirs(bind)
     self.bind = bind
     self.umask = umask
     self.logfile = logfile or os.path.join(self.cwd, 'fcgi.log')
     self.pidfile = pidfile or os.path.join(self.cwd, 'fcgi.pid')
     self.fastcgi_params = fastcgi_params or {}
Exemple #6
0
    def command_start(self, daemonize=False):
        '''
        Start a server::

            ./manage.py flup:start [--daemonize]
        '''
        if daemonize:
            safe_makedirs(self.logfile, self.pidfile)
        flup_fastcgi(self.app,
                     bind=self.bind,
                     pidfile=self.pidfile,
                     logfile=self.logfile,
                     daemonize=daemonize,
                     cwd=self.cwd,
                     umask=self.umask,
                     **self.fastcgi_params)
Exemple #7
0
 def __init__(self,
              app,
              bind='',
              logfile=None,
              pidfile=None,
              cwd='.',
              umask=2,
              fastcgi_params=None):
     self.app = app
     self.cwd = os.path.abspath(cwd)
     if ':' in bind:
         host, port = bind.split(':')
         port = int(port)
     else:
         bind = os.path.abspath(bind or os.path.join(self.cwd, 'fcgi.sock'))
         safe_makedirs(bind)
     self.bind = bind
     self.umask = umask
     self.logfile = logfile or os.path.join(self.cwd, 'fcgi.log')
     self.pidfile = pidfile or os.path.join(self.cwd, 'fcgi.pid')
     self.fastcgi_params = fastcgi_params or {}
Exemple #8
0
 def command_start(self, daemonize=False):
     if daemonize:
         safe_makedirs(self.logfile, self.pidfile)
     flup_fastcgi(self.app, bind=self.bind, pidfile=self.pidfile,
                  logfile=self.logfile, daemonize=daemonize,
                  cwd=self.cwd, umask=self.umask, **self.fastcgi_params)
Exemple #9
0
    fcgi.WSGIServer(wsgi_app, bindAddress=bind, umask=umask,
                    debug=False, **params).run()


class Flup(Cli):

    def __init__(self, app, bind='', logfile=None, pidfile=None,
                 cwd='.', umask=002, fastcgi_params=None):
        self.app = app
        self.cwd = os.path.abspath(cwd)
        if ':' in bind:
            host, port = bind.split(':')
            port = int(port)
        else:
            bind = os.path.abspath(bind or os.path.join(self.cwd, 'fcgi.sock'))
            safe_makedirs(bind)
        self.bind = bind
        self.umask = umask
        self.logfile = logfile or os.path.join(self.cwd, 'fcgi.log')
        self.pidfile = pidfile or os.path.join(self.cwd, 'fcgi.pid')
        self.fastcgi_params = fastcgi_params or {}

    def command_start(self, daemonize=False):
        if daemonize:
            safe_makedirs(self.logfile, self.pidfile)
        flup_fastcgi(self.app, bind=self.bind, pidfile=self.pidfile,
                     logfile=self.logfile, daemonize=daemonize,
                     cwd=self.cwd, umask=self.umask, **self.fastcgi_params)

    def _wait_pid(self, pid):
        try: