A simple jobs queue for easy projects like a home server. The most minimal system requirements is only php 7.4+. A queue can use different drivers to store information. Currently only works with files. I would be glad for your help in connecting drivers
For servers with limited resources and simple projects. I am using this queue for my home server. When I need to give the server a long task like a long processing or downloading a file and go about my business.
- Lightweight and ready to go out of the box
- The job gets queued even if the worker is not currently running. The worker will do the job as soon as it is started
- Minimum setup: Only php is needed to work. Keeping a worker running is also easy without special tools: you can add a lock file parameter and write the task to cron.
Do not use this project for large projects. It's not designed to handle a lot of tasks, workers and servers
- PHP 7.4+
it is all ;)
- Run
git clone git@github.com:Catsys/q-server.git
in work dir or download zip file and unzip in work dir. - Go to work dir and run worker
php q-server.php worker
. The worker must always be running. You can use supervisor, crontab or other to keep things running - Run job from your project like
cd /path/to/q-server-project/ && php q-server.php put --cmd='php /path/to/your-project/script.php'
The main idea is that full-fledged bash commands are sent to the queue. This makes it more flexible given that it's designed to run on a single server.
php q-server.php worker
php q-server.php put --cmd='cd path/to/project/ && php command.php' --comment='run my command'
. It return unique job process ID. Soon it will be possible to control the process by this id. But right now it only talks about successfully placing the job in the queue
Command | Description |
---|---|
put |
put job in queue |
worker |
run listener. Listens to the queue and executes the jobs. Your task is to maintain the constant performance of the worker |
stop |
stop all workers |
list |
show a list of all jobs in the queue |
status |
show worker status |
help |
run help command |
log |
show last 50 lines from log file. Use --lines=10 for change lines limit |
Parameter | Default | Description |
---|---|---|
cmd |
not required | command for run on |
comment |
null | just comment for list command |
id |
generated by script | command id. optional |
delay |
0 | delay before run in seconds |
tries |
1 | tries for run before kill job |
tries_delay |
180 (3 min) | delay between tries in seconds |
Parameter | Default | Description |
---|---|---|
single-mode |
false |
Prevent second instance from starting |
silent-mode |
false |
All output send to log file. |
sleep |
3 | delay between job searches in seconds. Reduces the number of requests to the storage |
- Run
crontab -e
- insert
* * * * * PATH_TO_QSERVER/q-server worker --single-mode=true
where PATH_TO_WORKER replaced to worker dir in your server.
Create and place the following config file in supervisor scope. Replace PATH_TO_WORKER to worker dir in your server.
[program:qserver]
command=PATH_TO_QSERVER/q-server worker --sleep=3
autostart=true
autorestart=true
- Mysql driver
- More drivers for the driver god
- Once run job in worker by id
- Kill job by id