Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Last active February 17, 2021 05:10
Show Gist options
  • Save kwilczynski/6c6645dfdc8de4cd9ed1 to your computer and use it in GitHub Desktop.
Save kwilczynski/6c6645dfdc8de4cd9ed1 to your computer and use it in GitHub Desktop.
kafka.service for systemd
[Unit]
Description=Apache Kafka server (broker)
Documentation=http://kafka.apache.org/documentation.html
Requires=network.target remote-fs.target syslog.target
After=network.target remote-fs.target syslog.target
ConditionPathExists=/etc/kafka/server.properties
ConditionPathExists=/var/lib/kafka
[Service]
Type=simple
PIDFile=/var/run/kafka.pid
User=kafka
Group=kafka
WorkingDirectory=/var/lib/kafka
EnvironmentFile=/etc/sysconfig/kafka
ExecStart=
ExecStop=
Restart=on-failure
SyslogIdentifier=kafka
[Install]
WantedBy=multi-user.target
@gianluca-sabena
Copy link

Use Type=simple instead of forking otherwise systemd will throw a timeout error. See http://stackoverflow.com/questions/28776520/systemd-service-for-jar-file-gets-operation-timed-out-error-after-few-minues-o

@kwilczynski
Copy link
Author

@gianluca-sabena thank you for pointing this out! And for taking the time to comment, you are awesome!

Note: I have updated the gist as per your comment 👍

@vide
Copy link

vide commented Dec 2, 2015

@kwilczynski what do you use as "ExecStart"? I'm using right know the java + classpath + java options and kinda works but I can't leverage EnvironmentFile this way (I'm on Debian and using /etc/default/kafka as EnvironmentFile)

@kwilczynski
Copy link
Author

@vide why you can't leverage EnvironmentFile? It should expose anything you put there to ExecStart for you to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment