# Path: pushmanager/core/pid.py
# def is_process_alive(pid):
# def kill_processes(pids):
# def check(path):
# def write(path, append=False, pid=None):
# def remove(path):


import logging
import os
import pwd
import signal
import sys
import time
import daemon
import tornado.ioloop
from abc import ABCMeta
from abc import abstractmethod
from optparse import OptionParser
from pushmanager.core import pid
from pushmanager.core.settings import Settings

        if self.command == "stop":
            for worker_pid in self.queue_worker_pids:
                os.kill(worker_pid, signal.SIGKILL)
            sys.exit()

    def parse_command(self):
        usage = "Usage: %prog start|stop"
        parser = OptionParser(usage=usage)
        _, args = parser.parse_args()

        if len(args) != 1 and args[0] not in ('start', 'stop'):
            parser.print_help()
            sys.exit(1)

        return args[0]

    def clean_pids(self):
        if os.path.exists(self.pid_file):
            pid.check(self.pid_file)
            os.unlink(self.pid_file)
            time.sleep(1)

    @abstractmethod
    def start_services(self):
        pass

    def run(self):
        daemon_context = daemon.DaemonContext(stdout=self.log, stderr=self.log, working_directory=os.getcwd())
        with daemon_context:

# Path: pushmanager/core/pid.py
# def is_process_alive(pid):
# def kill_processes(pids):
# def check(path):
# def write(path, append=False, pid=None):
# def remove(path):


# Path: pushmanager/core/application.py
import logging
import os
import pwd
import signal
import sys
import time
import daemon
import tornado.ioloop
from abc import ABCMeta
from abc import abstractmethod
from optparse import OptionParser
from pushmanager.core import pid
from pushmanager.core.settings import Settings


        if self.command == "stop":
            for worker_pid in self.queue_worker_pids:
                os.kill(worker_pid, signal.SIGKILL)
            sys.exit()

    def parse_command(self):
        usage = "Usage: %prog start|stop"
        parser = OptionParser(usage=usage)
        _, args = parser.parse_args()

        if len(args) != 1 and args[0] not in ('start', 'stop'):
            parser.print_help()
            sys.exit(1)

        return args[0]

    def clean_pids(self):
        if os.path.exists(self.pid_file):
            pid.check(self.pid_file)
            os.unlink(self.pid_file)
            time.sleep(1)

    @abstractmethod
    def start_services(self):
        pass

    def run(self):
        daemon_context = daemon.DaemonContext(stdout=self.log, stderr=self.log, working_directory=os.getcwd())
        with daemon_context:

            pid.write(self.pid_file, append=True)