示例#1
0
    def create_configuration(self, config):
        self.checks = []

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in list(sup.tree.programs):
            if p.comment and p.comment == self.COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                cfg = website.extension_configs.get(ProcessesExtension.classname) or {}
                for process in cfg.get('processes', []):
                    p = ProgramData()
                    p.comment = self.COMMENT
                    p.name = '%s-%s' % (website.slug, process['name'])
                    p.command = process['command']
                    p.environment = process['environment']
                    p.directory = process['directory'] or website.root
                    p.user = process['user'] or 'www-data'
                    p.stopasgroup = True
                    p.killasgroup = True
                    sup.tree.programs.append(p)
                    self.checks.append(ProcessTest(p.name))

        sup.save()
示例#2
0
    def create_configuration(self, config):
        self.checks = []

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in list(sup.tree.programs):
            if p.comment and p.comment == self.COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                cfg = website.extension_configs.get(
                    ProcessesExtension.classname) or {}
                for process in cfg.get('processes', []):
                    p = ProgramData()
                    p.comment = self.COMMENT
                    p.name = '%s-%s' % (website.slug, process['name'])
                    p.command = process['command']
                    p.environment = process['environment']
                    p.directory = process['directory'] or website.root
                    p.user = process['user'] or 'www-data'
                    p.stopasgroup = True
                    p.killasgroup = True
                    sup.tree.programs.append(p)
                    self.checks.append(ProcessTest(p.name))

        sup.save()
示例#3
0
    def create_configuration(self, config):
        self.checks = []
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        for website in config.websites:
            if website.enabled:
                self.__generate_website(website)

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()

        COMMENT = 'Generated by Ajenti-V'

        for p in sup.tree.programs:
            if p.comment == COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'python-wsgi':
                        self.checks.append(GUnicornServerTest(
                            location.backend))
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.comment = COMMENT
                        p.command = 'gunicorn -c %s/%s "%s"' % (
                            self.config_dir, location.backend.__config_name,
                            location.backend.params['module'])
                        p.directory = location.path or website.root
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = 'PATH="%s:%s"' % (os.path.join(
                                virtualenv, 'bin'), os.environ['PATH'])
                            p.command = os.path.join(virtualenv,
                                                     'bin') + '/' + p.command

                        sup.tree.programs.append(p)

        sup.save()
示例#4
0
文件: gunicorn.py 项目: pfz/ajenti-v
    def create_configuration(self, config):
        self.checks = []
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        for website in config.websites:
            if website.enabled:
                self.__generate_website(website)

        sup = SupervisorConfig(
            path=platform_select(debian="/etc/supervisor/supervisord.conf", centos="/etc/supervisord.conf")
        )
        sup.load()

        COMMENT = "Generated by Ajenti-V"

        for p in sup.tree.programs:
            if p.comment == COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == "python-wsgi":
                        self.checks.append(GUnicornServerTest(location.backend))
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.comment = COMMENT
                        p.command = 'gunicorn -c %s/%s "%s"' % (
                            self.config_dir,
                            location.backend.id,
                            location.backend.params["module"],
                        )
                        p.directory = location.path or website.root
                        virtualenv = location.backend.params.get("venv", None)
                        if virtualenv:
                            p.environment = 'PATH="%s"' % os.path.join(virtualenv, "bin")
                            p.command = os.path.join(virtualenv, "bin") + "/" + p.command

                        sup.tree.programs.append(p)

        sup.save()
示例#5
0
    def create_configuration(self, config):
        self.checks = []
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        for website in config.websites:
            if website.enabled:
                self.__generate_website(website)

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()

        COMMENT = 'Generated by Ajenti-V'

        for p in sup.tree.programs:
            if p.comment == COMMENT:
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'python-wsgi':
                        self.checks.append(GUnicornServerTest(location.backend))
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.user = location.backend.params.get('user', None) or 'www-data'
                        p.comment = COMMENT
                        p.command = 'gunicorn -c %s/%s "%s"' % (self.config_dir, location.backend.__config_name, location.backend.params['module'])
                        p.directory = location.path or website.root
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = 'PATH="%s"' % os.path.join(virtualenv, 'bin')
                            p.command = os.path.join(virtualenv, 'bin') + '/' + p.command

                        sup.tree.programs.append(p)

        sup.save()