Back to Deployer

Supervisord-monitor Recipe

docs/contrib/supervisord-monitor.md

8.0.33.0 KB
Original Source
<!-- DO NOT EDIT THIS FILE! --> <!-- Instead edit contrib/supervisord-monitor.php --> <!-- Then run bin/docgen -->

Supervisord-monitor Recipe

php
require 'contrib/supervisord-monitor.php';

Source

Description

This is a recipe that uses the Supervisord server monitoring project. With this recipe the possibility is created to restart a supervisord process through the Supervisor Monitor webtool, by using cURL. This workaround is particular usefull when the deployment user has unsuficient rights to restart a daemon process from the cli.

Configuration

set('supervisord', [
    'uri' => 'https://youruri.xyz/supervisor',
    'basic_auth_user' => 'username',
    'basic_auth_password' => 'password',
    'process_name' => 'process01',
]);

or

set('supervisord_uri', 'https://youruri.xyz/supervisor');
set('supervisord_basic_auth_user', 'username');
set('supervisord_basic_auth_password', 'password');
set('supervisord_process_name', 'process01');
  • supervisord – array with configuration for Supervisord
    • uri – URI to the Supervisord monitor page
    • basic_auth_user – Basic auth username to access the URI
    • basic_auth_password – Basic auth password to access the URI
    • process_name – the process name, as visible in the Supervisord monitor page. Multiple processes can be listed here, comma separated

Task

  • supervisord-monitor:restart Restarts given processes
  • supervisord-monitor:stop Stops given processes
  • supervisord-monitor:start Starts given processes

Usage

A complete example with configs, staging and deployment

<?php
namespace Deployer;
use Dotenv\Dotenv;
require 'vendor/autoload.php';
require 'supervisord_monitor.php';
Project name
set('application', 'myproject.com');
Project repository
set('repository', '[email protected]:myorg/myproject.com');
set('supervisord', [
    'uri' => 'https://youruri.xyz/supervisor',
    'basic_auth_user' => 'username',
    'basic_auth_password' => 'password',
    'process_name' => 'process01',
]);
host('staging.myproject.com')
    ->set('branch', 'develop')
    ->set('labels', ['stage' => 'staging']);
host('myproject.com')
    ->set('branch', 'main')
    ->set('labels', ['stage' => 'production']);
Tasks
task('build', function () {
    run('cd {{release_path}} && build');
});
task('deploy', [
    'build',
    'supervisord',
]);
task('supervisord', ['supervisord-monitor:restart'])
    ->select('stage=production');

Tasks

supervisord-monitor:restart {#supervisord-monitor-restart}

Source

supervisord-monitor:stop {#supervisord-monitor-stop}

Source

supervisord-monitor:start {#supervisord-monitor-start}

Source