Trap handlers: always log to stdout

Since the scripts are intended to be used as systemd services, there's
no need in separate logging via syslog: systemd will take care of
properly collecting and storing script output. Hence we can drop extra
options and function parameters.

Change-Id: Ifcad1877d45d43b3a2e617775a1c9b256e190591
Related: SYS#4399
changes/35/12135/2
Maxim Suraev 4 years ago
parent 25a8297fe8
commit f0f8a352cc
  1. 2
      contrib/systemd/osmo-ctrl2cgi.service
  2. 6
      osmopy/trap_helper.py
  3. 3
      scripts/ctrl2cgi.py
  4. 3
      scripts/soap.py

@ -4,7 +4,7 @@ Description=Proxy between given GCI service and Osmocom CTRL protocol
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/ctrl2cgi.py -o -d -c /etc/osmocom/ctrl2cgi.ini
ExecStart=/usr/bin/ctrl2cgi.py -d -c /etc/osmocom/ctrl2cgi.ini
RestartSec=2
[Install]

@ -95,7 +95,7 @@ def reloader(path, script, log, dbg1, dbg2, signum, _):
sys.argv.remove(dbg2)
os.execl(path, script, *sys.argv[1:])
def debug_init(name, is_debug, output):
def debug_init(name, is_debug):
"""
Initialize signal handlers and logging
"""
@ -104,9 +104,7 @@ def debug_init(name, is_debug, output):
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
log.addHandler(logging.handlers.SysLogHandler('/dev/log'))
if output:
log.addHandler(logging.StreamHandler(sys.stdout))
log.addHandler(logging.StreamHandler(sys.stdout))
reboot = partial(reloader, os.path.abspath(__file__), os.path.basename(__file__), log, '-d', '--debug') # keep in sync with caller's add_argument()
signal.signal(signal.SIGHUP, reboot)

@ -148,13 +148,12 @@ if __name__ == '__main__':
p.add_argument('-p', '--port-ctrl', type=int, default=4250, help="Port to use for CTRL interface, defaults to 4250")
p.add_argument('-n', '--num-max-conn', type=int, default=5, help="Max number of concurrent HTTP requests to CGI server")
p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") # keep in sync with debug_init call below
p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT in addition to SYSLOG")
p.add_argument('-l', '--location', help="Location URL of the CGI server")
p.add_argument('-s', '--secret-key', help="Secret key used to generate verification token")
p.add_argument('-c', '--config-file', help="Path Config file. Cmd line args override values in config file")
args = p.parse_args()
log = debug_init('CTRL2CGI', args.debug, args.output)
log = debug_init('CTRL2CGI', args.debug)
location_cfgfile = None
secret_key_cfgfile = None

@ -136,11 +136,10 @@ if __name__ == '__main__':
p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP")
p.add_argument('-n', '--num', type=int, default=5, help="Max number of concurrent HTTP requests to SOAP server")
p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") # keep in sync with debug_init call below
p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT in addition to SYSLOG")
p.add_argument('-l', '--location', help="Override location found in WSDL file (don't use unless you know what you're doing)")
args = p.parse_args()
log = debug_init('CTRL2SOAP', args.debug, args.output)
log = debug_init('CTRL2SOAP', args.debug)
log.info("SOAP proxy %s starting with PID %d ..." % (__version__, os.getpid()))
reactor.connectTCP(args.ctrl, args.port, TrapFactory(args.ctrl, args.port, Trap, defer.DeferredSemaphore(args.num), log, args.wsdl, args.location))

Loading…
Cancel
Save