From a4ff475abde01b33d4208b9e3c037a631f40f5fb Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Oct 2020 11:57:11 +0500 Subject: [PATCH 1/2] Fix logging --- webhook-catcher | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webhook-catcher b/webhook-catcher index 2cf95ad..d551c79 100755 --- a/webhook-catcher +++ b/webhook-catcher @@ -136,6 +136,8 @@ class WebHookHandler(BaseHTTPRequestHandler): self.end_headers() self.wfile.write(json.dumps(self.json_response, indent=2, sort_keys=True).encode('UTF-8', 'replace')) + def log_message(self, format, *args): + pm("%s - - [%s] %s \n" % (self.address_string(), self.log_date_time_string(), format%args)) def do_POST(self): # GET SIGNATURE @@ -422,10 +424,12 @@ class MessagePrinter: def pm(self, message): if not self.quiet: print(message) + sys.stdout.flush() def pdm(self, debug_message): if self.debug: pprint(debug_message) + sys.stdout.flush() def load_config(path): if path != '': From 76e62815c5a61bec3a991177692f556c21e283e3 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Oct 2020 12:02:11 +0500 Subject: [PATCH 2/2] Add sample systemd unit file --- systemd/webhook-catcher.service | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 systemd/webhook-catcher.service diff --git a/systemd/webhook-catcher.service b/systemd/webhook-catcher.service new file mode 100644 index 0000000..8c2398c --- /dev/null +++ b/systemd/webhook-catcher.service @@ -0,0 +1,12 @@ +[Unit] +Description=Webhook catcher +After=network.target + +[Service] +User=whcd +Group=whcd + +ExecStart=/usr/sbin/webhook-catcher -c /etc/webhook-catcher/config.json + +[Install] +WantedBy=multi-user.target