Page MenuHomePhabricator

No OneTemporary

diff --git a/msrprelay b/msrprelay
index 897f3bc..14a399c 100644
--- a/msrprelay
+++ b/msrprelay
@@ -1,90 +1,90 @@
#!/usr/bin/env python
"""MSRP Relay"""
if __name__ == '__main__':
import msrp
import sys
import signal
from application import log
from application.process import process, ProcessError
from argparse import ArgumentParser
name = 'msrprelay'
fullname = 'MSRP Relay'
description = 'An open source MSRP Relay'
process.configuration.user_directory = None
process.configuration.subdirectory = name
# process.runtime.subdirectory = name
parser = ArgumentParser(usage='%(prog)s [options]')
parser.add_argument('--version', action='version', version='%(prog)s {}'.format(msrp.__version__))
parser.add_argument('--systemd', action='store_true', help='run as a systemd simple service and log to journal')
parser.add_argument('--no-fork', action='store_false', dest='fork', help='run in the foreground and log to terminal')
- parser.add_argument('--config-dir', dest='config_directory', default=None, help='the configuration directory', metavar='PATH')
+ parser.add_argument('--config-dir', dest='config_directory', default=None, help='the configuration directory ({})'.format(process.configuration.system_directory), metavar='PATH')
parser.add_argument('--runtime-dir', dest='runtime_directory', default=None, help='the runtime directory ({})'.format(process.runtime.directory), metavar='PATH')
parser.add_argument('--debug', action='store_true', help='enable verbose logging')
parser.add_argument('--debug-memory', action='store_true', help='enable memory debugging')
options = parser.parse_args()
log.Formatter.prefix_format = '{record.levelname:<8s} '
if options.config_directory is not None:
process.configuration.local_directory = options.config_directory
if options.runtime_directory is not None:
process.runtime.directory = options.runtime_directory
if options.systemd:
from systemd.journal import JournalHandler
log.set_handler(JournalHandler(SYSLOG_IDENTIFIER=name))
log.capture_output()
elif options.fork:
try:
pid_file = '{}.pid'.format(name)
process.daemonize(pid_file)
except ProcessError, e:
log.critical('Cannot start %s: %s' % (fullname, e))
sys.exit(1)
log.use_syslog(name)
log.info('Starting %s %s' % (fullname, msrp.__version__))
try:
process.wait_for_network(wait_time=10, wait_message='Waiting for network to become available...')
except KeyboardInterrupt:
sys.exit(0)
except RuntimeError as e:
log.critical('Cannot start %s: %s' % (fullname, e))
sys.exit(1)
from msrp.relay import Relay, RelayConfig
log.level.current = log.level.DEBUG if options.debug else RelayConfig.log_level
if options.debug_memory:
from application.debug.memory import memory_dump
try:
relay = Relay()
except Exception, e:
log.critical('Failed to create %s: %s' % (fullname, e))
if e.__class__ is not RuntimeError:
log.exception()
sys.exit(1)
process.signals.add_handler(signal.SIGHUP, lambda signum, frame: relay.reload())
try:
relay.run()
except Exception, e:
log.critical('Failed to run %s: %s' % (fullname, e))
if e.__class__ is not RuntimeError:
log.exception()
sys.exit(1)
if options.debug_memory:
memory_dump()

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 3:30 AM (19 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3408715
Default Alt Text
(3 KB)

Event Timeline