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.db import Database
|
|
|
|
from xenu_nntp.server import Server
|
|
|
|
from xenu_nntp.daemon import Daemon
|
2024-12-03 16:07:40 -05:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Tiny NNTP server')
|
2024-12-04 12:15:15 -05:00
|
|
|
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
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2024-12-04 12:15:15 -05:00
|
|
|
config = Config.load(args.config_file)
|
2024-12-03 16:07:40 -05:00
|
|
|
server = Server(config)
|
|
|
|
|
|
|
|
if args.daemon:
|
2024-12-03 16:53:31 -05:00
|
|
|
Daemon.init(config)
|
2024-12-03 16:07:40 -05:00
|
|
|
|
2024-12-05 00:18:23 -05:00
|
|
|
try:
|
|
|
|
server.run()
|
|
|
|
except KeyboardInterrupt:
|
2024-12-07 06:39:05 -05:00
|
|
|
server.stop()
|