AccelerateNetworks / PagingServer

SIP-based Announcement / PA / Paging / Public Address Server system
GNU General Public License v2.0
28 stars 14 forks source link

Server context manager #11

Closed mk-fg closed 9 years ago

mk-fg commented 9 years ago

"Configure - init - run - destroy" server lifecycle pattern, python-way as:

with PagingServer(config, sd_cycle) as server:
    for sig in signal.SIGINT, signal.SIGTERM:
        signal.signal(sig, lambda sig,frm: server.destroy())
    server.run()

With proper container for all server-y stuff instead of globals.

Also properly integrates systemd watchdog calls into run() loop via lib.handle_events(), no more while True: sleep() nonsense, pjsua can run in the main thread just fine.

Based on systemd and cli/logging stuff from #8 and #9.