def run(self): smtp_server.start()
if initialize_database(): log.info("Database successfully initialized") if __name__ == '__main__': parser = ArgumentParser() parser.add_argument("-d", "--daemon", help="run as a daemon") parser.add_argument("-a", "--address", default=smtp_server_domain, help="bind address") parser.add_argument("-p", "--port", type=int, default=smtp_server_port, help="bind port") args = parser.parse_args() if not args.daemon: set_foreground_logger() _setup_db() # not daemon, just run in foreground. log.info("Starting smtp listener on as %s:%s", smtp_server_domain, str(smtp_server_port)) smtp_server.start() else: daemon = PseudoSMTPDaemon('/tmp/pseudo_smtp.pid') if args.daemon == 'start': _setup_db() daemon.start() elif args.daemon == 'stop': daemon.stop() elif args.daemon == 'restart': daemon.restart() elif args.daemon == 'status': daemon.status()
parser.add_argument("-d", "--daemon", help="run as a daemon") parser.add_argument("-a", "--address", default=smtp_server_domain, help="bind address") parser.add_argument("-p", "--port", type=int, default=smtp_server_port, help="bind port") args = parser.parse_args() if not args.daemon: set_foreground_logger() _setup_db() # not daemon, just run in foreground. log.info("Starting smtp listener on as %s:%s", smtp_server_domain, str(smtp_server_port)) smtp_server.start() else: daemon = PseudoSMTPDaemon('/tmp/pseudo_smtp.pid') if args.daemon == 'start': _setup_db() daemon.start() elif args.daemon == 'stop': daemon.stop() elif args.daemon == 'restart': daemon.restart() elif args.daemon == 'status': daemon.status()