From 82f38245ca10e4c1608df60fe71d893b15f64077 Mon Sep 17 00:00:00 2001 From: Paul Wouters Date: Tue, 1 Mar 2022 15:35:26 -0500 Subject: [PATCH] daemon: use setproctitle to name process journalpump This way, the process shows up as journalpump and not as one of many python processes. --- debian/control | 2 +- journalpump.spec | 4 ++-- journalpump/daemon.py | 3 +++ requirements.dev.txt | 1 + requirements.txt | 3 ++- setup.py | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/debian/control b/debian/control index 7cc03c9..2f45196 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Depends: ${misc:Depends}, ${python3:Depends}, adduser, python3-elasticsearch, python3-kafka, python3-requests, python3-systemd, python3-boto3, python3-googleapi, - python3-websockets, python3-aiohttp-socks, python3-snappy + python3-websockets, python3-aiohttp-socks, python3-snappy, python3-setproctitle Description: daemon that takes log messages from journald and pumps them to a given output. Currently supported outputs are Elasticsearch, Kafka, Websocket, logplex, AWS CloudWatch and Google Cloud Logging. It reads diff --git a/journalpump.spec b/journalpump.spec index f619493..29b7cb6 100644 --- a/journalpump.spec +++ b/journalpump.spec @@ -7,10 +7,10 @@ License: ASL 2.0 Source0: journalpump-rpm-src.tar.gz Requires: python3-kafka, systemd-python3, python3-requests, python3-boto3, python3-google-api-client Requires: python3-oauth2client, python3-geoip2, python3-typing-extensions -Requires: python3-websockets, python3-aiohttp-socks, python3-snappy +Requires: python3-websockets, python3-aiohttp-socks, python3-snappy python3-setproctitle BuildRequires: python3-kafka, systemd-python3, python3-requests, python3-boto3, python3-google-api-client BuildRequires: python3-devel, python3-pytest, python3-pylint python3-responses -BuildRequires: python3-websockets, python3-aiohttp-socks, python3-snappy +BuildRequires: python3-websockets, python3-aiohttp-socks, python3-snappy python3-setproctitle BuildArch: noarch Obsoletes: kafkajournalpump diff --git a/journalpump/daemon.py b/journalpump/daemon.py index a68a32b..b0a3c6b 100644 --- a/journalpump/daemon.py +++ b/journalpump/daemon.py @@ -6,6 +6,7 @@ Common Daemon functionality """ +from setproctitle import setproctitle from systemd import daemon, journal import json @@ -14,6 +15,7 @@ import signal import sys + LOG_FORMAT = "%(asctime)s\t%(name)s\t%(levelname)s\t%(message)s" LOG_FORMAT_JOURNAL = "%(name)-20s %(levelname)-8s %(message)s" LOG_FORMAT_JOURNAL_MULTI_THREAD = "%(name)-20s %(threadName)-15s %(levelname)-8s %(message)s" @@ -111,6 +113,7 @@ def main(cls, args): try: exe = cls(config_path=args[0]) daemon.notify("READY=1") + setproctitle("journalpump") return exe.run() except ServiceDaemonError as ex: logging.fatal("%s failed to start: %s", cls.__name__, ex) diff --git a/requirements.dev.txt b/requirements.dev.txt index 22b0d6c..e5975e4 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -14,3 +14,4 @@ coverage coveralls responses unify +setproctitle diff --git a/requirements.txt b/requirements.txt index c83dad9..7f05dca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ google-api-python-client oauth2client geoip2 https://github.com/systemd/python-systemd/zipball/master -typing-extensions \ No newline at end of file +typing-extensions +setproctitle diff --git a/setup.py b/setup.py index 16fb730..960d4ea 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ "oauth2client", "geoip2", "typing-extensions", + "setproctitle", ], dependency_links=[], package_data={},