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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ $eventId = $spinupwp->servers->reboot($serverId);
// Restart the Nginx service on a server
$eventId = $spinupwp->servers->restartNginx($serverId);

// Restart the Redis service on a server
$eventId = $spinupwp->servers->restartRedis($serverId);

// Restart all versions of the PHP-FPM service installed on a server
$eventId = $spinupwp->servers->restartPhp($serverId);

Expand All @@ -62,6 +65,9 @@ $server->reboot();
// Restart the Nginx service on the current server
$server->restartNginx();

// Restart the Redis service on the current server
$server->restartRedis();

// Restart all versions of the PHP-FPM service installed on the current server
$server->restartPhp();

Expand Down
7 changes: 7 additions & 0 deletions src/Endpoints/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public function restartNginx(int $id): int
return $request['event_id'];
}

public function restartRedis(int $id): int
{
$request = $this->postRequest("servers/{$id}/services/redis/restart");

return $request['event_id'];
}

public function restartPhp(int $id): int
{
$request = $this->postRequest("servers/{$id}/services/php/restart");
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function restartNginx(): int
return $this->spinupwp->servers->restartNginx($this->id);
}

public function restartRedis(): int
{
return $this->spinupwp->servers->restartRedis($this->id);
}

public function restartPhp(): int
{
return $this->spinupwp->servers->restartPhp($this->id);
Expand Down
9 changes: 9 additions & 0 deletions tests/Endpoints/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ public function test_restart_nginx(): void
$this->assertEquals(100, $this->serverEndpoint->restartNginx(1));
}

public function test_restart_redis(): void
{
$this->client->shouldReceive('request')->once()->with('POST', 'servers/1/services/redis/restart', [])->andReturn(
new Response(200, [], '{"event_id": 100}')
);

$this->assertEquals(100, $this->serverEndpoint->restartRedis(1));
}

public function test_restart_php(): void
{
$this->client->shouldReceive('request')->once()->with('POST', 'servers/1/services/php/restart', [])->andReturn(
Expand Down