Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ $ploi->servers(123)->opcache()->disable();

// Refresh opcache
$ploi->servers(123)->opcache()->refresh();

// Run a one-off script on a server
$response = $ploi->servers(123)->runOneOffScript('npm install -g pm2', $user = 'deployer');
$executionId = $response->getData()->id;

// Poll one-off script execution status and output
$ploi->servers(123)->getScriptExecution($executionId);
```

### Sites
Expand Down Expand Up @@ -632,6 +639,12 @@ $ploi->scripts(123)->delete();

// Run script
$ploi->scripts(123)->run($id = null, $serverIds = []);

// Run a one-off script on a server (no reusable script resource needed)
$ploi->servers(123)->runOneOffScript($content, $user = null);

// Get one-off script execution status
$ploi->servers(123)->getScriptExecution($executionId);
```

### Daemons
Expand Down
22 changes: 22 additions & 0 deletions src/Ploi/Resources/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,28 @@ public function restart(?int $id = null): Response
return $this->callApi('restart', 'post');
}

public function runOneOffScript(string $content, ?string $user = null): Response
{
$this->setIdOrFail();

$body = ['content' => $content];

if ($user !== null) {
$body['user'] = $user;
}

return $this->callApi('scripts/run', 'post', [
'body' => json_encode($body),
]);
}

public function getScriptExecution(string $executionId): Response
{
$this->setIdOrFail();

return $this->callApi("scripts/run/{$executionId}");
}

public function monitoring(?int $id = null): Response
{
$this->setIdOrFail($id);
Expand Down