(self, service_name, args)
Script setup.

        User class should override work() and optionally __init__(), startup(),
        reload(), reset(), shutdown() and init_optparse().

        NB: In case of daemon, __init__() and startup()/work()/shutdown() will be
        run in different processes.  So nothing fancy should be done in __init__().

        @param service_name: unique name for script.
            It will be also default job_name, if not specified in config.
        @param args: cmdline args (sys.argv[1:]), but can be overridden
Script setup.
Script setup .
def __init__(self, service_name, args):
        """Script setup.

        User class should override work() and optionally __init__(), startup(),
        reload(), reset(), shutdown() and init_optparse().

        NB: In case of daemon, __init__() and startup()/work()/shutdown() will be
        run in different processes.  So nothing fancy should be done in __init__().

        @param service_name: unique name for script.
            It will be also default job_name, if not specified in config.
        @param args: cmdline args (sys.argv[1:]), but can be overridden
        """
        self.service_name = service_name
        self.go_daemon = 0
        self.need_reload = 0
        self.exception_count = 0
        self.stat_dict = {}
        self.log_level = logging.INFO

        # parse command line
        parser = self.init_optparse()
        self.options, self.args = parser.parse_args(args)

        # check args
        if self.options.version:
            self.print_version()
            sys.exit(0)
        if self.options.daemon:
            self.go_daemon = 1
        if self.options.quiet:
            self.log_level = logging.WARNING
        if self.options.verbose > 1:
            self.log_level = skytools.skylog.TRACE
        elif self.options.verbose:
            self.log_level = logging.DEBUG

        self.cf_override = {}
        if self.options.set:
            for a in self.options.set:
                k, v = a.split('=', 1)
                self.cf_override[k.strip()] = v.strip()

        if self.options.ini:
            self.print_ini()
            sys.exit(0)

        # read config file
        self.reload()

        # init logging
        _init_log(self.job_name, self.service_name, self.cf, self.log_level, self.go_daemon)

        # send signal, if needed
        if self.options.cmd == "kill":
            self.send_signal(signal.SIGTERM)
        elif self.options.cmd == "stop":
            self.send_signal(signal.SIGINT)
        elif self.options.cmd == "reload":
            self.send_signal(signal.SIGHUP)
def __init__ ( self , service_name , args ) : self . service_name = service_name self . go_daemon = 0 self . need_reload = 0 self . exception_count = 0 self . stat_dict = { } self . log_level = logging . INFO # parse command line parser = self . init_optparse ( ) self . options , self . args = parser . parse_args ( args ) # check args if self . options . version : self . print_version ( ) sys . exit ( 0 ) if self . options . daemon : self . go_daemon = 1 if self . options . quiet : self . log_level = logging . WARNING if self . options . verbose > 1 : self . log_level = skytools . skylog . TRACE elif self . options . verbose : self . log_level = logging . DEBUG self . cf_override = { } if self . options . set : for a in self . options . set : k , v = a . split ( '=' , 1 ) self . cf_override [ k . strip ( ) ] = v . strip ( ) if self . options . ini : self . print_ini ( ) sys . exit ( 0 ) # read config file self . reload ( ) # init logging _init_log ( self . job_name , self . service_name , self . cf , self . log_level , self . go_daemon ) # send signal, if needed if self . options . cmd == "kill" : self . send_signal ( signal . SIGTERM ) elif self . options . cmd == "stop" : self . send_signal ( signal . SIGINT ) elif self . options . cmd == "reload" : self . send_signal ( signal . SIGHUP )