Exemplo n.º 1
0
    def __restart_service(self, name):
        try:
            service = Service.create(name)
            service.restart()

        except ServiceError as exc:
            print exc
Exemplo n.º 2
0
    def __stop_service(self, name):
        try:
            service = Service.create(name)
            service.stop()

        except ServiceError as exc:
            print exc
Exemplo n.º 3
0
    def __get_started_services(self):
        started_services = {}
        for name in os.listdir(Service.pid_path):
            if name.endswith('.pid'):
                service_name = name[:-4]

                with open(os.path.join(Service.pid_path, name)) as f:
                    pid = f.read().strip()

                if pid in self.__get_all_started_pids(
                ):  # checking started pid
                    started_services[service_name] = pid
                else:
                    service = Service.create(service_name, None)
                    service.remove_pidfile()

        return started_services