2024-12-03 16:07:40 -05:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
|
2024-12-30 20:54:09 -05:00
|
|
|
from xenu_nntp.config import Config
|
|
|
|
from xenu_nntp.server import Server
|
|
|
|
from xenu_nntp.daemon import Daemon
|
2024-12-03 16:07:40 -05:00
|
|
|
|
2025-01-05 00:15:24 -05:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(description='Tiny NNTP server')
|
|
|
|
parser.add_argument('--daemon', '-d', action='store_true', help='Run NNTP server as daemon in background')
|
|
|
|
parser.add_argument('--config-file', '-f', type=str, help='Specify a configuration file location')
|
2024-12-03 16:07:40 -05:00
|
|
|
|
2025-01-05 00:15:24 -05:00
|
|
|
args = parser.parse_args()
|
2024-12-03 16:07:40 -05:00
|
|
|
|
2025-01-05 00:15:24 -05:00
|
|
|
config = Config.load(args.config_file)
|
|
|
|
server = Server(config)
|
2024-12-03 16:07:40 -05:00
|
|
|
|
2025-01-05 00:15:24 -05:00
|
|
|
if args.daemon:
|
|
|
|
Daemon.init(config)
|
2024-12-03 16:07:40 -05:00
|
|
|
|
2025-01-05 00:15:24 -05:00
|
|
|
try:
|
|
|
|
server.run()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
server.stop()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
exit(main())
|