Ejemplo n.º 1
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = '%s %s' % (
                            node_bin,
                            location.backend.params.get('script', None) or '.'
                        )
                        p.user = location.backend.params.get('user', None) or 'www-data'
                        p.environment = location.backend.params.get('environment', None) or ''
                        p.directory = location.path or website.root
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 2
0
class Supervisor (SectionPlugin):
    def init(self):
        self.title = 'Supervisor'
        self.icon = 'play'
        self.category = _('Software')
        self.append(self.ui.inflate('supervisor:main'))
        self.mgr = SupervisorServiceManager.get()
        self.binder = Binder(None, self.find('main'))
        self.find('programs').new_item = lambda c: ProgramData()
        self.config = SupervisorConfig(path=platform_select(
            default='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        self.find('servicebar').name = platform_select(
            centos='supervisord',
            default='supervisor',
        )
        self.find('servicebar').reload()

    def on_page_load(self):
        self.refresh()

    def refresh(self):
        self.config.load()
        self.mgr.fill(self.config.tree.programs)
        self.binder.setup(self.config.tree).populate()

    @on('save', 'click')
    def on_save(self):
        self.binder.update()
        self.config.save()
        self.refresh()
Ejemplo n.º 3
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path="/etc/supervisor/supervisord.conf")
        sup.load()
        for p in sup.tree.programs:
            if p.command.startswith("puma") or p.command.startswith("bundle exec puma"):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == "ruby-puma":
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        bundler = location.backend.params.get("bundler", True)
                        workers = location.backend.params.get("workers", 4)
                        environment = location.backend.params.get("environment", 4)
                        p.command = "puma -e %s -t %i -b unix:///var/run/puma-%s.sock" % (
                            environment,
                            workers,
                            location.backend.id,
                        )
                        if bundler:
                            p.command = "bundle exec " + p.command
                        p.environment = 'HOME="%s"' % website.root
                        p.directory = website.root
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
class Supervisor(SectionPlugin):
    def init(self):
        self.title = 'Supervisor'
        self.icon = 'play'
        self.category = _('Software')
        self.append(self.ui.inflate('supervisor:main'))
        self.mgr = SupervisorServiceManager.get()
        self.binder = Binder(None, self.find('main'))
        self.find('programs').new_item = lambda c: ProgramData()
        self.config = SupervisorConfig(path=platform_select(
            default='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        self.find('servicebar').name = platform_select(
            centos='supervisord',
            default='supervisor',
        )
        self.find('servicebar').reload()

    def on_page_load(self):
        self.refresh()

    def refresh(self):
        self.config.load()
        self.mgr.fill(self.config.tree.programs)
        self.binder.setup(self.config.tree).populate()

    @on('save', 'click')
    def on_save(self):
        self.binder.update()
        self.config.save()
        self.refresh()
Ejemplo n.º 6
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 sup.tree.programs:
            if p.command.startswith('puma') or p.command.startswith('bundle exec puma'):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'ruby-puma':
                        self.checks.append(PumaServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id
                        bundler = location.backend.params.get('bundler', True)
                        workers = location.backend.params.get('workers', 4)
                        environment = location.backend.params.get('environment', 4)
                        p.command = 'puma -e %s -t %i -b unix:///var/run/puma-%s.sock' % (
                            environment, workers or 4, location.backend.id
                        )
                        if bundler:
                            p.command = 'bundle exec ' + p.command
                        p.environment = 'HOME="%s"' % website.root
                        p.directory = website.root
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 7
0
 def init(self):
     self.title = 'Supervisor'
     self.icon = 'play'
     self.category = _('Software')
     self.append(self.ui.inflate('supervisor:main'))
     self.mgr = SupervisorServiceManager.get()
     self.binder = Binder(None, self.find('main'))
     self.find('programs').new_item = lambda c: ProgramData()
     self.config = SupervisorConfig(path='/etc/supervisor/supervisord.conf')
Ejemplo n.º 8
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id

             		command = location.backend.params.get('script', None)
                        if command.find("npm ") == -1 :
                            command = '%s %s' % (
                                node_bin,
                                location.backend.params.get('script', None) or '.'
                            )

                        p.user = location.backend.params.get('user', None) or 'www-data'
                        p.directory = location.path or website.root

                        p.environment = location.backend.params.get('environment', None) or ''
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = '; '.join([p.environment, 'PATH="%s:%s"' % (os.path.join(virtualenv, 'bin'), os.environ['PATH'])])
                            p.command = os.path.join(virtualenv, 'bin') + '/' + command
                        else:
                            p.command = command


                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 9
0
 def init(self):
     self.title = 'Supervisor'
     self.icon = 'play'
     self.category = _('Software')
     self.append(self.ui.inflate('supervisor:main'))
     self.mgr = SupervisorServiceManager.get()
     self.binder = Binder(None, self.find('main'))
     self.find('programs').new_item = lambda c: ProgramData()
     self.config = SupervisorConfig(path=platform_select(
         default='/etc/supervisor/supervisord.conf',
         centos='/etc/supervisord.conf',
     ))
     self.find('servicebar').name = platform_select(
         centos='supervisord',
         default='supervisor',
     )
     self.find('servicebar').reload()
Ejemplo n.º 10
0
 def init(self):
     self.title = 'Supervisor'
     self.icon = 'play'
     self.category = 'Software'
     self.append(self.ui.inflate('supervisor:main'))
     self.mgr = SupervisorServiceManager.get()
     self.binder = Binder(None, self.find('main'))
     self.find('programs').new_item = lambda c: ProgramData()
     self.config = SupervisorConfig(path='/etc/supervisor/supervisord.conf')
Ejemplo n.º 11
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.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()
Ejemplo n.º 12
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()
Ejemplo n.º 13
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path='/etc/supervisor/supervisord.conf')
        sup.load()
        for p in sup.tree.programs:
            if p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                i = 0
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        i += 1
                        location.backend.id = website.slug + '-nodejs-' + str(i)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = 'node %s' % location.backend.params.get('path', '/')
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 14
0
    def create_configuration(self, config):
        if os.path.exists(self.config_dir):
            shutil.rmtree(self.config_dir)
        os.mkdir(self.config_dir)

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('unicorn'):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'ruby-unicorn':
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = 'unicorn_rails -E production -c %s/%s.rb' % (self.config_dir, location.backend.id)
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 15
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                i = 0
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        i += 1
                        location.backend.id = website.slug + '-nodejs-' + str(
                            i)
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = 'node %s' % location.backend.params.get(
                            'path', '/')
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 16
0
    def create_configuration(self, config):
        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command.startswith('puma') or p.command.startswith(
                    'bundle exec puma'):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'ruby-puma':
                        self.__generate_website(website)
                        p = ProgramData()
                        p.name = location.backend.id
                        bundler = location.backend.params.get('bundler', True)
                        workers = location.backend.params.get('workers', 4)
                        environment = location.backend.params.get(
                            'environment', 4)
                        p.command = 'puma -e %s -t %i -b unix:///var/run/puma-%s.sock' % (
                            environment, workers, location.backend.id)
                        if bundler:
                            p.command = 'bundle exec ' + p.command
                        p.environment = 'HOME="%s"' % website.root
                        p.directory = website.root
                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 17
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()
Ejemplo n.º 18
0
class Supervisor(SectionPlugin):
    def init(self):
        self.title = 'Supervisor'
        self.icon = 'play'
        self.category = 'Software'
        self.append(self.ui.inflate('supervisor:main'))
        self.mgr = SupervisorServiceManager.get()
        self.binder = Binder(None, self.find('main'))
        self.find('programs').new_item = lambda c: ProgramData()
        self.config = SupervisorConfig(path='/etc/supervisor/supervisord.conf')

    def on_page_load(self):
        self.refresh()

    def refresh(self):
        self.config.load()
        self.mgr.fill(self.config.tree.programs)
        self.binder.reset(self.config.tree).autodiscover().populate()

    @on('save', 'click')
    def on_save(self):
        self.binder.update()
        self.config.save()
        self.refresh()
Ejemplo n.º 19
0
class Supervisor (SectionPlugin):
    def init(self):
        self.title = 'Supervisor'
        self.icon = 'play'
        self.category = 'Software'
        self.append(self.ui.inflate('supervisor:main'))
        self.mgr = SupervisorServiceManager.get()
        self.binder = Binder(None, self.find('main'))
        self.find('programs').new_item = lambda c: ProgramData()
        self.config = SupervisorConfig(path='/etc/supervisor/supervisord.conf')

    def on_page_load(self):
        self.refresh()

    def refresh(self):
        self.config.load()
        self.mgr.fill(self.config.tree.programs)
        self.binder.reset(self.config.tree).autodiscover().populate()

    @on('save', 'click')
    def on_save(self):
        self.binder.update()
        self.config.save()
        self.refresh()
Ejemplo n.º 20
0
 def init(self):
     self.title = 'Supervisor'
     self.icon = 'play'
     self.category = _('Software')
     self.append(self.ui.inflate('supervisor:main'))
     self.mgr = SupervisorServiceManager.get()
     self.binder = Binder(None, self.find('main'))
     self.find('programs').new_item = lambda c: ProgramData()
     self.config = SupervisorConfig(path=platform_select(
         default='/etc/supervisor/supervisord.conf',
         centos='/etc/supervisord.conf',
     ))
     self.find('servicebar').name = platform_select(
         centos='supervisord',
         default='supervisor',
     )
     self.find('servicebar').reload()
Ejemplo n.º 21
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id

                        command = location.backend.params.get('script', None)
                        if command.find("npm ") == -1:
                            command = '%s %s' % (node_bin,
                                                 location.backend.params.get(
                                                     'script', None) or '.')

                        p.user = location.backend.params.get(
                            'user', None) or 'www-data'
                        p.directory = location.path or website.root

                        p.environment = location.backend.params.get(
                            'environment', None) or ''
                        virtualenv = location.backend.params.get('venv', None)
                        if virtualenv:
                            p.environment = '; '.join([
                                p.environment,
                                'PATH="%s:%s"' % (os.path.join(
                                    virtualenv, 'bin'), os.environ['PATH'])
                            ])
                            p.command = os.path.join(virtualenv,
                                                     'bin') + '/' + command
                        else:
                            p.command = command

                        sup.tree.programs.append(p)

        sup.save()
Ejemplo n.º 22
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()
Ejemplo n.º 23
0
    def create_configuration(self, config):
        self.checks = []

        node_bin = 'node'
        try:
            subprocess.call(['which', 'node'])
        except:
            node_bin = 'nodejs'

        sup = SupervisorConfig(path=platform_select(
            debian='/etc/supervisor/supervisord.conf',
            centos='/etc/supervisord.conf',
        ))
        sup.load()
        for p in sup.tree.programs:
            if p.command and p.command.startswith('node '):
                sup.tree.programs.remove(p)

        for website in config.websites:
            if website.enabled:
                for location in website.locations:
                    if location.backend.type == 'nodejs':
                        self.checks.append(NodeServerTest(location.backend))
                        p = ProgramData()
                        p.name = location.backend.id
                        p.command = '%s %s' % (node_bin,
                                               location.backend.params.get(
                                                   'script', None) or '.')
                        p.user = location.backend.params.get(
                            'user', None) or 'www-data'
                        p.environment = location.backend.params.get(
                            'environment', None) or ''
                        p.directory = location.path or website.root
                        sup.tree.programs.append(p)

        sup.save()