]> kaliko git repositories - mpd-sima.git/blobdiff - launch
Fixed prog name
[mpd-sima.git] / launch
diff --git a/launch b/launch
index f03ca5b120fcc753dc6035914bef19f8aa0ccd22..618e1bcb980ab99dbc14edaff21019ef7613f23e 100755 (executable)
--- a/launch
+++ b/launch
@@ -66,13 +66,15 @@ def load_internal_plugins(sima):
 def main():
     """Entry point, deal w/ CLI and starts application
     """
-    info = dict({'version': core.__version__,})
+    info = dict({'version': core.__version__,
+                 'prog': 'sima'})
     # StartOpt gathers options from command line call (in StartOpt().options)
     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 +104,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