Add systemd as an opttion for Queue Workers

This commit is contained in:
Carlos Ferreira 2018-09-12 12:36:54 +02:00 committed by GitHub
parent 7d9cc4c49f
commit a1026d8b67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,6 +55,55 @@ numprocs=4
redirect_stderr=true
stdout_logfile=<INSERT HUMHUB PATH HERE>/protected/runtime/logs/yii-queue-worker.log
```
Replace the user `www-data` with the user of your http server if needed.
***Using systemd***
If systemd is installed on the system, a systemd timer could be an alternative to a cronjob.
This approach requires two files: `humhub.service` and `humhub.timer`. Create these two files in `/etc/systemd/system/`.
`humhub.service` should look like this:
```
[Unit]
Description=HumHub Queue Worker
[Service]
User=www-data
ExecStart=/usr/bin/php <INSERT HUMHUB PATH HERE>/protected/yii queue/listen --verbose=1 --color=0
[Install]
WantedBy=basic.target
```
Replace the user `www-data` with the user of your http server if needed.
`humhub.timer` should look like this:
```
[Unit]
Description=Run HumHub Queue Workers every minute
[Timer]
OnBootSec=1min
OnUnitActiveSec=1min
Unit=humhub.service
[Install]
WantedBy=timers.target
```
The important parts in the timer-unit are `OnBootSec` and `OnUnitActiveSec`.
`OnBootSec` will start the timer 1 minute after boot, otherwise you would have to start it manually after every boot.
`OnUnitActiveSec` will set a 1 minute timer after the service-unit was last activated.
Now all that is left is to start and enable the timer by running these commands:
```
systemctl start humhub.timer
systemctl enable humhub.timer
```
Queue Driver
------------