katsana / minions-server
Minions Component Server using ReactPHP
Installs: 20 363
Dependents: 0
Suggesters: 1
Security: 0
Stars: 3
Watchers: 5
Forks: 1
Open Issues: 1
Requires
- illuminate/console: ^6.0 || ^7.0 || ^8.0
- katsana/minions: ^1.6 || ^2.1
- laravie/stream: ^1.3
- league/climate: ^3.5
- react/event-loop: ^1.1
- react/http: ^0.8.4
- react/promise: ^2.5
Requires (Dev)
- mockery/mockery: ^1.3.1
- orchestra/testbench: ^4.5 || ^5.0 || ^6.0
- phpunit/phpunit: ^8.4 || ^9.0
README
Installation
Minions can be installed via composer:
composer require "katsana/minions-server=^1.0"
Please ensure that you already install Minions and go through the installation and setup documentation.
Usages
Minion Server will run the RPC Server using ReactPHP running from Artisan command.
You can start the RPC server by issuing the artisan command:
php artisan minions:serve
Configurations
You can export the default minions-server.php
to your project directory via the following command:
php artisan vendor:publish --provider="Minions\Server\MinionsServiceProvider" --tag="config"
Using a different port
The default port of the RPC server is 8085
. You may set a different port by updating the environment file (or config/minions.php
).
MINION_SERVER_PORT=8081
Restricting the listening host
By default, the RPC server will listen on 127.0.0.1
and will only allow incoming connections from local networks. If you want to expose this, you set a different host updating the environment file (or config/minions.php
).
MINION_SERVER_HOST='0.0.0.0'
Keeping the socket server running with supervisord
The minions:serve
daemon needs to always be running in order to accept connections. This is a prime use case for supervisor
, a task runner on Linux.
First, make sure supervisor
is installed.
# On Debian / Ubuntu
apt install supervisor
# On Red Hat / CentOS
yum install supervisor
systemctl enable supervisor
Once installed, add a new process that supervisor needs to keep running. You place your configurations in the /etc/supervisor/conf.d
(Debian/Ubuntu) or /etc/supervisord.d
(Red Hat/CentOS) directory.
Within that directory, create a new file called minions.conf
.
[program:minion]
command=/usr/bin/php /home/project/artisan minions:serve
numprocs=1
autostart=true
autorestart=true
Once created, instruct supervisor
to reload it's configuration files (without impacting the already running supervisor
jobs).
supervisorctl update
supervisorctl start minion
Your RPC server should now be running (you can verify this with supervisorctl status
). If it were to crash, supervisor
will automatically restart it.
Please note that, by default, supervisor
will force a maximum number of open files onto all the processes that it manages. This is configured by the minfds
parameter in supervisord.conf
.
If you want to increase the maximum number of open files, you may do so in /etc/supervisor/supervisord.conf
(Debian/Ubuntu) or /etc/supervisord.conf
(Red Hat/CentOS):
[supervisord]
minfds=10240; (min. avail startup file descriptors;default 1024)
After changing this setting, you'll need to restart the supervisor
process (which in turn will restart all your processes that it manages).