Supervisor Manager

PHP

Plesk extension for managing Supervisor processes and workers with monitoring, process control, service management, and deployment automation.

Stars
16
Forks
1
Downloads
N/A
Open Issues
0
Files main

Repository Files

Loading file structure...
plib/views/scripts/index/add.phtml
<?php
$data = $this->formData;
$domainQuery = !empty($this->domainQuery) ? $this->domainQuery : '';
$domainParam = strpos($domainQuery, 'site_id=') !== false ? 'site_id' : 'dom_id';
$action = pm_Context::getBaseUrl() . 'index.php/index/save' . $domainQuery;
$cancel = pm_Context::getBaseUrl() . 'index.php/index/index' . $domainQuery;
?>

<?php if (!empty($this->error)): ?>
    <div class="sm-message sm-message-error"><?php echo $this->escape($this->error); ?></div>
<?php endif; ?>

<form class="sm-editor" method="post" action="<?php echo $this->escape($action); ?>">
    <?php if (!empty($data['id'])): ?>
        <input type="hidden" name="id" value="<?php echo $this->escape($data['id']); ?>">
    <?php endif; ?>
    <?php if (!empty($this->domainContext)): ?>
        <input type="hidden" name="domain_id" value="<?php echo (int) $this->domainId; ?>">
        <input type="hidden" name="context_domain_id" value="<?php echo (int) $this->domainId; ?>">
        <input type="hidden" name="context_domain_param" value="<?php echo $this->escape($domainParam); ?>">
    <?php endif; ?>

    <div class="sm-editor-head">
        <h1><?php echo empty($data['id']) ? 'Add Supervisor Program' : 'Edit Supervisor Program'; ?></h1>
        <p>Save writes the Supervisor config and returns to the manager page.</p>
    </div>

    <label>
        <span>Supervisor Program Name *</span>
        <input type="text" name="name" required value="<?php echo $this->escape($data['name']); ?>" placeholder="queue-worker">
        <em>Exact Supervisor process name, for example queue-worker or websocket-server.</em>
    </label>

    <label>
        <span>Display Name</span>
        <input type="text" name="display_name" value="<?php echo $this->escape($data['display_name']); ?>" placeholder="Queue Worker">
    </label>

    <?php if (!empty($this->domainContext)): ?>
        <div class="sm-locked-domain">
            <span>Assigned Domain</span>
            <strong><?php echo $this->escape($this->domainName ?: ('ID ' . $this->domainId)); ?></strong>
            <em>This program will be created only for this domain.</em>
        </div>
    <?php else: ?>
        <label>
            <span>Assigned Domain *</span>
            <select name="domain_id" required>
                <option value="">Select domain</option>
                <?php foreach ($this->domains as $id => $name): ?>
                    <option value="<?php echo (int) $id; ?>" <?php echo (int) $data['domain_id'] === (int) $id ? 'selected' : ''; ?>>
                        <?php echo $this->escape($name); ?>
                    </option>
                <?php endforeach; ?>
            </select>
        </label>
    <?php endif; ?>

    <label class="sm-editor-wide">
        <span>Command *</span>
        <textarea name="command" rows="3" required placeholder="php artisan queue:work"><?php echo $this->escape($data['command']); ?></textarea>
        <em>Use a long-running process, for example php artisan queue:work, npm run worker, or /usr/bin/python3 worker.py. Version checks like php -v exit immediately.</em>
    </label>

    <label>
        <span>Project Root</span>
        <input type="text" name="working_directory" value="<?php echo $this->escape($data['working_directory']); ?>" placeholder="/var/www/vhosts/example.com/app">
        <em>Folder containing artisan/package.json. Must stay inside the selected domain area.</em>
    </label>

    <div class="sm-checks">
        <label>
            <input type="checkbox" name="autostart" value="1" <?php echo !empty($data['autostart']) ? 'checked' : ''; ?>>
            <span>Start on boot</span>
        </label>
        <label>
            <input type="checkbox" name="autorestart" value="1" <?php echo !empty($data['autorestart']) ? 'checked' : ''; ?>>
            <span>Restart if it exits</span>
        </label>
        <label>
            <input type="checkbox" name="enabled" value="1" <?php echo !empty($data['enabled']) ? 'checked' : ''; ?>>
            <span>Enabled</span>
        </label>
    </div>

    <label class="sm-editor-wide">
        <span>Notes</span>
        <textarea name="description" rows="4"><?php echo $this->escape($data['description']); ?></textarea>
    </label>

    <div class="sm-editor-actions">
        <button class="btn action" type="submit">Save</button>
        <a class="btn" href="<?php echo $this->escape($cancel); ?>">Cancel</a>
    </div>
</form>