ricbra / rabbitmq-cli-consumer

Consume RabbitMQ messages into any cli program
MIT License
247 stars 49 forks source link

sigterm & error only output support #62

Closed adrianrudnik closed 3 years ago

adrianrudnik commented 6 years ago

Hi, not sure it's still interesting to some, I made some small changes to allow for clean exists through OS signals.

Here is an example I use for myself on Ubuntu with systemd in /etc/systemd/system/app-queue.service:

[Unit]
Description=App Queue Processor
After=network.service

[Service]
User=www-data
Group=www-data
Type=simple

Restart=on-failure
RestartSec=10

WorkingDirectory=/var/webapp
Environment="APP_QUEUE_CONF=/var/webapp/app/config/rabbitmq.queue.conf"
Environment="APP_QUEUE_EXEC=/var/webapp/bin/console app:queue:mails:process"

ExecStart=/usr/bin/rabbitmq-cli-consumer -V -c ${APP_QUEUE_CONF} -e ${APP_QUEUE_EXEC}

[Install]
WantedBy=multi-user.target

Reloading, enabling and starting the new service:

systemctl daemon-reload
systemctl enable app-queue.service
systemctl start app-queue.service

In the second commit I made a change that allows the config file to have no log-files defined. As I'm only interested in errors (and restarts) and everything else can be controlled through the service definition or viewed through journalctl, this was quite a pain, esp. if the executable should be run as www-data.

Golang is not my main language, I hope I made no grave mistakes.