Skip to content

Instantly share code, notes, and snippets.

@samveen
Forked from thomasjsn/laravel-queue.service
Last active January 12, 2022 06:10
Show Gist options
  • Save samveen/b747168897d9fc3f7c4309f0041c0fc4 to your computer and use it in GitHub Desktop.
Save samveen/b747168897d9fc3f7c4309f0041c0fc4 to your computer and use it in GitHub Desktop.
Laravel queue worker unit template for systemd.
# Laravel systemd queue worker unit template
# ----------------------------------
#
# /etc/systemd/system/laravel-queue@.service
# Config at /etc/laravel-queue-${INSTANCE}.conf
#
# To enable an instance of this service:
# - Create a conf file /etc/-laravel-queue-SOME_NAME.conf which contains:
# - LARAVEL_USER= (required)
# - LARAVEL_GROUP= (required)
# - LARAVEL_ROOT= (required)
# - LARAVEL_EXTRA_PARAMS= (optional)
# - Enabe the unit instance:
# - systemctl enable laravel-queue@SOME_NAME.service
# WARNING:
# This is for systemd-219 (Centos 7) which does NOT
# support following directives:
# - WorkingDirectory - v228 - nice to have, but php changes CWD to dir of first parameter anyway
# - StandardOutput - v240 - not needed - use journalctl -u
# - StandardOutput - v240 - not needed - use journalctl -u
[Unit]
Description=Laravel queue worker
# enforce start before httpd
Before=httpd.service
RequiredBy=httpd.service
[Service]
EnvironmentFile="%E/laravel-queue-%i.conf"
User=${LARAVEL_USER}
Group=${LARAVEL_GROUP}
Restart=always
ExecStart=/usr/bin/php ${LARAVEL_ROOT} queue:work --daemon --env=production ${LARAVEL_EXTRA_PARAMS}
[Install]
WantedBy=multi-user.target
WantedBy=httpd.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment