mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
51
app/SSH/Systemd/Systemd.php
Normal file
51
app/SSH/Systemd/Systemd.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSH\Systemd;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class Systemd
|
||||
{
|
||||
public function __construct(protected Server $server)
|
||||
{
|
||||
}
|
||||
|
||||
public function status(string $unit): string
|
||||
{
|
||||
$command = <<<EOD
|
||||
sudo service $unit status | cat
|
||||
EOD;
|
||||
|
||||
return $this->server->ssh()->exec($command, sprintf('status-%s', $unit));
|
||||
}
|
||||
|
||||
public function start(string $unit): string
|
||||
{
|
||||
$command = <<<EOD
|
||||
sudo service $unit start
|
||||
sudo service $unit status | cat
|
||||
EOD;
|
||||
|
||||
return $this->server->ssh()->exec($command, sprintf('start-%s', $unit));
|
||||
}
|
||||
|
||||
public function stop(string $unit): string
|
||||
{
|
||||
$command = <<<EOD
|
||||
sudo service $unit stop
|
||||
sudo service $unit status | cat
|
||||
EOD;
|
||||
|
||||
return $this->server->ssh()->exec($command, sprintf('stop-%s', $unit));
|
||||
}
|
||||
|
||||
public function restart(string $unit): string
|
||||
{
|
||||
$command = <<<EOD
|
||||
sudo service $unit restart
|
||||
sudo service $unit status | cat
|
||||
EOD;
|
||||
|
||||
return $this->server->ssh()->exec($command, sprintf('restart-%s', $unit));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user