Commit b697d003 authored by Henry Krumb's avatar Henry Krumb
Browse files

add debug option

parent e97c7d21
Pipeline #5786 passed with stage
in 3 minutes and 14 seconds
......@@ -15,7 +15,7 @@ import logging
import os
import subprocess
import sys
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.WARNING)
class ModeratedMic:
......@@ -81,12 +81,10 @@ class ModeratedMic:
return
locked_state = "locked" if locked else "unlocked"
logging.debug(f"caller {caller_num} pressed 0, they are in a {locked_state} meeting.")
logging.debug("fs_member_id:", fs_member_id)
logging.debug(f"fs_member_id: {fs_member_id}")
try:
if not locked:
logging.debug(self.fs.send(f"api conference {conference_id} tmute {fs_member_id}").data)
else:
logging.debug(self.fs.send(f"api conference {conference_id} mute {fs_member_id}").data)
command = 'mute' if locked else 'tmute'
logging.debug(self.fs.send(f"api conference {conference_id} {command} {fs_member_id}").data)
except KeyError as e:
# TODO investigate what actually happens here
logging.warning("Error when sending (t)mute:")
......@@ -160,21 +158,28 @@ class ModeratedMic:
@click.command()
@click.option('--debug', '-d', is_flag=True)
@click.argument(
'mode',
type=click.Choice(['zero_key_handler', 'redis_handler']),
required=False
)
def main(mode):
def main(mode, debug):
if debug:
logging.getLogger().setLevel(logging.DEBUG)
# no command line args supplied:
# spawns two subprocesses for 0-key and redis handlers
if not mode:
interpreter_path = sys.executable
flags = []
if debug:
flags.append('-d')
zero_key_handler = subprocess.Popen([
interpreter_path, '-u', sys.argv[0], 'zero_key_handler'
interpreter_path, '-u', sys.argv[0], 'zero_key_handler', *flags
])
redis_handler = subprocess.Popen([
interpreter_path, '-u', sys.argv[0], 'redis_handler'
interpreter_path, '-u', sys.argv[0], 'redis_handler', *flags
])
zero_key_handler.wait()
redis_handler.wait()
......
......@@ -7,7 +7,7 @@ PartOf=freeswitch.service
[Service]
Type=simple
WorkingDirectory=/opt/senfsip-moderated-mute
ExecStart=/bin/bash -c "source venv/bin/activate && ./events.py"
ExecStart=/bin/bash -c "source venv/bin/activate && ./events.py --debug"
Restart=always
[Install]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment