X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=launch;h=13528b7559e769e1fa4929b6f1c7e7a339dcf082;hb=cf5fee72c57cf6b6f09b9caa78ab9e547f1d7542;hp=f03ca5b120fcc753dc6035914bef19f8aa0ccd22;hpb=3232d76fccc3b431bd42a34a5f182667efa346d0;p=mpd-sima.git diff --git a/launch b/launch index f03ca5b..13528b7 100755 --- a/launch +++ b/launch @@ -71,8 +71,9 @@ def main(): sopt = StartOpt(info) # set logger verbosity = sopt.options.get('verbosity', 'warning') + logfile = sopt.options.get('logfile', None) cli_loglevel = getattr(logging, verbosity.upper()) - set_logger(level=verbosity) + set_logger(level=verbosity, logfile=logfile) logger = logging.getLogger('sima') logger.setLevel(cli_loglevel) # loads configuration @@ -102,21 +103,30 @@ def main(): # Loading contrib plugins load_contrib_plugins(sima) + + # Run as a daemon + if config.getboolean('daemon', 'daemon'): + sima.start() + try: - sima.run() + sima.foreground() except KeyboardInterrupt: logger.info('Caught KeyboardInterrupt, stopping') - sima.shutdown() + #sima.shutdown() -# Script starts here -if __name__ == '__main__': +def run(): + """Catching broad exception + """ # pylint: disable=broad-except try: main() except Exception: exception_log() +# Script starts here +if __name__ == '__main__': + run() # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab