Skip to content

Commit

Permalink
daemon: use setproctitle to name process journalpump
Browse files Browse the repository at this point in the history
This way, the process shows up as journalpump and not as one of many
python processes.
  • Loading branch information
paulwouters committed Mar 1, 2022
1 parent 9f1a540 commit 82f3824
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions journalpump.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions journalpump/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Common Daemon functionality
"""
from setproctitle import setproctitle
from systemd import daemon, journal

import json
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ coverage
coveralls
responses
unify
setproctitle
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ google-api-python-client
oauth2client
geoip2
https://github.com/systemd/python-systemd/zipball/master
typing-extensions
typing-extensions
setproctitle
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"oauth2client",
"geoip2",
"typing-extensions",
"setproctitle",
],
dependency_links=[],
package_data={},
Expand Down

0 comments on commit 82f3824

Please sign in to comment.