This is the official bundle of the Supervisor PHP library.
Step 1: Install YZSupervisorBundle using Composer
Add YZSupervisorBundle in your composer.json
:
{
"require": {
"yzalis/supervisor-bundle": "1.0.*@dev"
}
}
Now tell composer to download the bundle by running the command:
$ php composer.phar update yzalis/supervisor-bundle
Enable the bundle in the kernel:
# app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new YZ\SupervisorBundle\YZSupervisorBundle(),
// ...
);
}
# app/config/config.yml
yz_supervisor:
default_environment: dev
servers:
prod:
SUPERVISOR_01:
host: 192.168.0.1
username: guest
password: password
port: 9001
SUPERVISOR_02:
host: 192.168.0.2
username: guest
password: password
port: 9001
dev:
locahost:
host: 127.0.0.1
username: guest
password: password
port: 9001
groups: ['example_site']
The group option limits access to specific process groups. When no groups are provided, all groups are listed.
Iterate over all supervisor servers:
$supervisorManager = $this->container->get('supervisor.manager');
foreach ($supervisorManager->getSupervisors() as $supervisor) {
echo $supervisor->getKey();
// ...
}
Retrieve a specific supervisor servers:
$supervisorManager = $this->container->get('supervisor.manager');
$supervisor = $supervisorManager->getSupervisorByKey('uniqueKey');
echo $supervisor->getKey();
You can access to a beautiful user interface to monitor all your supervisor servers an process.
Import the routing definition in routing.yml
:
# app/config/routing.yml
YZSupervisorBundle:
resource: "@YZSupervisorBundle/Resources/config/routing.xml"
prefix: /supervisor
Here is the result
To run unit tests, you'll need a set of dependencies you can install using Composer:
php composer.phar install
Once installed, just launch the following command:
phpunit
You're done.
- Benjamin Laugueux benjamin@yzalis.com
- All contributors
Supervisor is released under the MIT License. See the bundled LICENSE file for details.