From 5eebcb6815761048b23552d158b9fe773c4d9e42 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 19 Apr 2022 15:03:29 +0100 Subject: [PATCH] Add LOGFILE configuration --- rigel/README.md | 2 +- rigel/server.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rigel/README.md b/rigel/README.md index 18caed6..4681824 100644 --- a/rigel/README.md +++ b/rigel/README.md @@ -16,7 +16,7 @@ script like: ``` Rigel will listen to the tcp port provided by HOST and PORT vars in `.env`(at the root of -project) and converts any text messages that gets into speech on the fly. +project. Checkout `env.example`) and converts any text messages that gets into speech on the fly. The protocol is pretty simple. The packet should start with 32 bit unsigned integer that contains the length of the string that comes after it. That's it. diff --git a/rigel/server.py b/rigel/server.py index e342e7f..f739562 100755 --- a/rigel/server.py +++ b/rigel/server.py @@ -36,6 +36,9 @@ if __name__ == "__main__": config = dotenv.dotenv_values(sys.argv[1]) action = sys.argv[2] pfile = config.get("PID_FILE", "/var/run/rigel.pid") + logs = config.get("LOGFILE") + logfile = open(logs, 'a+') if logs else sys.stdout + pidlock = pidfile.PIDFile(pfile) if action == "status": @@ -50,8 +53,8 @@ if __name__ == "__main__": print("Not running.") elif action == "start": - with daemon.DaemonContext(stdout=sys.stdout, - stderr=sys.stderr, + with daemon.DaemonContext(stdout=logfile, + stderr=logfile, pidfile=pidlock): main(config)