Beispiel #1
0
 def get_process_status(self, name=None):
     cfg_file = OnDemandStringIO(self.get_merged_config)
     args = list()
     if name is not None:
         args.append(name)
     try:            
         supervisorctl.main(("-c",cfg_file, "status") + tuple(args))
     except:
         pass
Beispiel #2
0
 def handle(self, *args, **options):
     from supervisor import supervisorctl
     supervisorctl.main(
         ['-c', '/etc/antilles/supervisord.conf', 'stop', 'all'])
     supervisorctl.main([
         '-c',
         '/etc/antilles/supervisord.conf',
         'shutdown',
     ])
Beispiel #3
0
    def logs(self, name, follow=False, tail=1600):
        cfg_file = OnDemandStringIO(self.get_merged_config)
        args = list()
        if follow:
            args.append("-f")
        else:
            args.append("-" + str(tail))
        args.append(name)

        try:            
            supervisorctl.main(("-c",cfg_file, "tail") + tuple(args))  
        except:
            pass
Beispiel #4
0
 def _handle_gracefulrestart(self, cfg_file, *args, **options):
     """Reload a process gracefully with SIGHUP"""
     oldstdout = sys.stdout
     sys.stdout = stdout = StringIO()
     args = ("pid",) + args
     supervisorctl.main(("-c", cfg_file) + args)
     output = stdout.getvalue()
     pids = output.split("\n")
     sys.stdout = oldstdout
     exit_code = 0
     for pid in pids:
         if pid:
             exit_code = os.kill(int(pid.strip()), signal.SIGHUP) or exit_code
     return exit_code
Beispiel #5
0
 def SvcStop(self):
     self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
     # Supervisor process stop event
     try:
         self.logger.info("supervisorctl shutdown")
         from supervisor import supervisorctl
         stdout = StringIO()
         supervisorctl.main(("-c", self.config_filepath, "shutdown"),
                            stdout=stdout)
         self.logger.info(stdout.getvalue().strip("\n "))
     except:
         self.logger.exception("supervisorctl shutdown execution failed")
     finally:
         logging.shutdown()
         win32event.SetEvent(self.hWaitStop)
Beispiel #6
0
    def handle(self, *args, **options):
        #  We basically just construct the merged supervisord.conf file
        #  and forward it on to either supervisord or supervisorctl.
        cfg = get_merged_config(**options)

        # If --dump was passed, just print the combined config file and exit
        if options.get('dump'):
            print cfg
            return

        #  Due to some very nice engineering on behalf of supervisord authors,
        #  you can pass it a StringIO instance for the "-c" command-line
        #  option.  Saves us having to write the config to a tempfile.
        cfg_file = StringIO(cfg)
        #  With no arguments, we launch the processes under supervisord.
        if not args:
            return supervisord.main(("-c",cfg_file))
        #  With arguments, the first arg specifies the sub-command
        #  Some commands we implement ourself with _handle_<command>.
        #  The rest we just pass on to supervisorctl.
        assert args[0].isalnum()
        methname = "_handle_%s" % (args[0],)
        try:
            method = getattr(self,methname)
        except AttributeError:
            return supervisorctl.main(("-c",cfg_file) + args)
        else:
            return method(cfg_file,*args[1:],**options)
Beispiel #7
0
    def handle(self, *args, **options):
        #  We basically just construct the merged supervisord.conf file
        #  and forward it on to either supervisord or supervisorctl.
        cfg = get_merged_config(**options)

        # If --dump was passed, just print the combined config file and exit
        if options.get('dump'):
            print cfg
            return

        #  Due to some very nice engineering on behalf of supervisord authors,
        #  you can pass it a StringIO instance for the "-c" command-line
        #  option.  Saves us having to write the config to a tempfile.
        cfg_file = StringIO(cfg)
        #  With no arguments, we launch the processes under supervisord.
        if not args:
            return supervisord.main(("-c", cfg_file))
        #  With arguments, the first arg specifies the sub-command
        #  Some commands we implement ourself with _handle_<command>.
        #  The rest we just pass on to supervisorctl.
        assert args[0].isalnum()
        methname = "_handle_%s" % (args[0], )
        try:
            method = getattr(self, methname)
        except AttributeError:
            return supervisorctl.main(("-c", cfg_file) + args)
        else:
            return method(cfg_file, *args[1:], **options)
    def handle(self, *args, **options):
        args = args or tuple(options.pop('ctl-command'))

        #  We basically just construct the merged supervisord.conf file
        #  and forward it on to either supervisord or supervisorctl.
        #  Due to some very nice engineering on behalf of supervisord authors,
        #  you can pass it a StringIO instance for the "-c" command-line
        #  option.  Saves us having to write the config to a tempfile.
        cfg_file = OnDemandStringIO(get_merged_config, **options)
        #  With no arguments, we launch the processes under supervisord.
        if not args:
            return supervisord.main(("-c",cfg_file))
        #  With arguments, the first arg specifies the sub-command
        #  Some commands we implement ourself with _handle_<command>.
        #  The rest we just pass on to supervisorctl.
        if not args[0].isalnum():
            raise ValueError("Unknown supervisor command: %s" % (args[0],))
        methname = "_handle_%s" % (args[0],)
        try:
            method = getattr(self,methname)
        except AttributeError:
            return supervisorctl.main(("-c",cfg_file) + args)
        else:
            return method(cfg_file,*args[1:],**options)
    def handle(self, *args, **options):
        args = args or tuple(options.pop('ctl-command'))

        #  We basically just construct the merged supervisord.conf file
        #  and forward it on to either supervisord or supervisorctl.
        #  Due to some very nice engineering on behalf of supervisord authors,
        #  you can pass it a StringIO instance for the "-c" command-line
        #  option.  Saves us having to write the config to a tempfile.
        cfg_file = OnDemandStringIO(get_merged_config, **options)
        #  With no arguments, we launch the processes under supervisord.
        if not args:
            return supervisord.main(("-c", cfg_file))
        #  With arguments, the first arg specifies the sub-command
        #  Some commands we implement ourself with _handle_<command>.
        #  The rest we just pass on to supervisorctl.
        if not args[0].isalnum():
            raise ValueError("Unknown supervisor command: %s" % (args[0], ))
        methname = "_handle_%s" % (args[0], )
        try:
            method = getattr(self, methname)
        except AttributeError:
            return supervisorctl.main(("-c", cfg_file) + args)
        else:
            return method(cfg_file, *args[1:], **options)
Beispiel #10
0
    def supervisorctl(self, *args, data: str = "./data"):
        from supervisor.supervisorctl import main

        main(("-c", Path(data) / SUPERVISOR_CONFIG_FILE, *args))
Beispiel #11
0
        from supervisor.supervisorctl import main

        main(("-c", Path(data) / SUPERVISOR_CONFIG_FILE, *args))

    def cli(self, *args, data: str = "./data", chain="chainmaind"):
        return ClusterCLI(Path(data), chain, self.cmd)

    def bot(
        self,
        *args,
        data: str = "./data",
        config_path: str = "./bot.yaml",
    ):
        """
        transaction bot CLI

        :param data: path to the root data directory
        :param config_path: path to the bot configuration file
        (copy bot.yaml.example for reference)
        """
        cluster_cli = ClusterCLI(Path(data), self.cmd)
        return BotCLI(config_path, cluster_cli)


def main():
    fire.Fire(CLI)


if __name__ == "__main__":
    main()
Beispiel #12
0
#!/usr/bin/env python
#

from supervisor import supervisorctl

supervisorctl.main()
Beispiel #13
0
 def handle(self, *args, **options):
     from supervisor import supervisorctl
     supervisorctl.main(['-c', '/etc/antilles/supervisord.conf', 'status'])
Beispiel #14
0
 def stop_process(self, name="all"):
     cfg_file = OnDemandStringIO(self.get_merged_config)
     try:
         supervisorctl.main(("-c",cfg_file, "stop", name))
     except:
         pass
Beispiel #15
0
 def signal_process(self, name="all", signal="SIGKILL"):
     cfg_file = OnDemandStringIO(self.get_merged_config)
     try:
         supervisorctl.main(("-c",cfg_file, "signal", signal, name))  
     except:
         pass
 def _handle_shell(self, cfg_file, *args, **options):
     """Command 'supervisord shell' runs the interactive command shell."""
     args = ("--interactive", ) + args
     return supervisorctl.main(("-c", cfg_file) + args)
Beispiel #17
0
 def supervisorctl(self, *args, **kwargs):
     supervisorctl.main(args=["-c", self.supervisord_conf_path] + list(args))
 def _handle_shell(self,cfg_file,*args,**options):
     """Command 'supervisord shell' runs the interactive command shell."""
     args = ("--interactive",) + args
     return supervisorctl.main(("-c",cfg_file) + args)
Beispiel #19
0
 def supervisorctl(self, *args, **kwargs):
     supervisorctl.main(args=['-c', self.supervisord_conf_path] +
                        list(args))