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()
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()
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()
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()
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()
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()
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()