Skip to content

Instantly share code, notes, and snippets.

@vishalzambre
Last active April 16, 2020 08:22
Show Gist options
  • Save vishalzambre/bedae6fa18457ac406a67aeba8129b35 to your computer and use it in GitHub Desktop.
Save vishalzambre/bedae6fa18457ac406a67aeba8129b35 to your computer and use it in GitHub Desktop.
System Service for resque
## Add System Service for Resque
Copy below code and paste to /lib/systemd/system/resque.service
`vim /lib/systemd/system/resque.service`
```shell
[Unit]
Description=Resque Workers
[Service]
WorkingDirectory=/var/app/current
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /var/run/resque_worker.pid
PIDFile=/var/run/resque_worker.pid
ExecStart=/usr/local/rbenv/bin/rbenv exec bundle exec rake resque:jobs:content &
Environment=RBENV_ROOT=/usr/local/rbenv
Environment=RBENV_VERSION=2.4.4
Environment=RAILS_ENV=production
TimeoutStopSec=0
Restart=always
User=www-data
Group=www-data
[Install]
WantedBy=multi-user.target
Alias=resque.service
```
Link Service
`ln -s /lib/systemd/system/resque.service /etc/systemd/system/resque.service`
Enable Service
`systemctl enable resque.service `
Reload daemon
`systemctl daemon-reload`
Start
`systemctl start resque.service`
Stop
`systemctl stop resque.service`
Status
`systemctl status resque.service`
To Remove unregistered workers
`Resque.workers.each {|w| w.unregister_worker}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment