Skip to content

Commit

Permalink
Run rabbitmq as user
Browse files Browse the repository at this point in the history
  • Loading branch information
mischabraam committed Sep 21, 2023
1 parent aaa0fa3 commit cb71681
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
8 changes: 7 additions & 1 deletion cli/ValetPlus/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use JsonException;
use Valet\Brew;
use Valet\CommandLine;
use Valet\Configuration;
use Valet\Filesystem;

Expand All @@ -22,22 +23,27 @@ abstract class AbstractService
protected $configClassName;
/** @var Brew */
protected $brew;
/** @var CommandLine */
protected $cli;
/** @var Filesystem */
protected $files;

/**
* @param Configuration $configuration
* @param Brew $brew
* @param Filesystem $files
* @param CommandLine $cli
*/
public function __construct(
Configuration $configuration,
Brew $brew,
Filesystem $files
Filesystem $files,
CommandLine $cli
) {
$this->configuration = $configuration;
$this->brew = $brew;
$this->files = $files;
$this->cli = $cli;
}

/**
Expand Down
61 changes: 55 additions & 6 deletions cli/ValetPlus/Extended/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@
use Valet\Status as ValetStatus;
use WeProvide\ValetPlus\Mailhog;
use WeProvide\ValetPlus\Mysql;
use WeProvide\ValetPlus\Rabbitmq;
use WeProvide\ValetPlus\Redis;
use WeProvide\ValetPlus\Varnish;

class Status extends ValetStatus
{
/** @var Mysql */
protected $mysql;
/** @var Mailhog */
protected $mailhog;
/** @var Varnish */
protected $varnish;
/** @var Redis */
protected $redis;
/** @var Rabbitmq */
protected $rabbitmq;

/**
* @param Configuration $config
Expand All @@ -26,19 +35,28 @@ class Status extends ValetStatus
* @param Filesystem $files
* @param Mysql $mysql
* @param Mailhog $mailhog
* @param Varnish $varnish
* @param Redis $redis
* @param Rabbitmq $rabbitmq
*/
public function __construct(
Configuration $config,
Brew $brew,
CommandLine $cli,
Filesystem $files,
Mysql $mysql,
Mailhog $mailhog
Mailhog $mailhog,
Varnish $varnish,
Redis $redis,
Rabbitmq $rabbitmq
) {
parent::__construct($config, $brew, $cli, $files);

$this->mysql = $mysql;
$this->mailhog = $mailhog;
$this->mysql = $mysql;
$this->mailhog = $mailhog;
$this->varnish = $varnish;
$this->redis = $redis;
$this->rabbitmq = $rabbitmq;
}

/**
Expand All @@ -53,20 +71,51 @@ public function checks(): array
$mysqlVersion = $this->mysql->installedVersion();

$checks[] = [
'description' => '[Valet+] Is Mysql ('.$mysqlVersion.') installed?',
'description' => '[Valet+] Is Mysql (' . $mysqlVersion . ') installed?',
'check' => function () {
return $this->mysql->installedVersion();
},
'debug' => 'Run `composer require weprovide/valet-plus` and `valet install`.'
'debug' => 'Run `composer require weprovide/valet-plus` and `valet-plus install`.'
];
$checks[] = [
'description' => '[Valet+] Is Mailhog installed?',
'check' => function () {
return $this->mailhog->installed();
},
'debug' => 'Run `composer require weprovide/valet-plus` and `valet install`.'
'debug' => 'Run `composer require weprovide/valet-plus` and `valet-plus install`.'
];

if ($this->varnish->installed() || $this->varnish->isEnabled()) {
$checks[] = [
'description' => '[Valet+] Is Varnish installed?',
'check' => function () {
return $this->varnish->installed() && $this->varnish->isEnabled();
},
'debug' => 'Varnish is installed but not enabled, you might run `valet-plus varnish on`.'
];
//todo; actually test something?
}
if ($this->redis->installed() || $this->redis->isEnabled()) {
$checks[] = [
'description' => '[Valet+] Is Redis installed?',
'check' => function () {
return $this->redis->installed() && $this->redis->isEnabled();
},
'debug' => 'Redis is installed but not enabled, you might run `valet-plus redis on`.'
];
//todo; actually test something?
}
if ($this->rabbitmq->installed() || $this->rabbitmq->isEnabled()) {
$checks[] = [
'description' => '[Valet+] Is Rabbitmq installed?',
'check' => function () {
return $this->rabbitmq->installed() && $this->rabbitmq->isEnabled();
},
'debug' => 'Rabbitmq is installed but not enabled, you might run `valet-plus rabbitmq on`.'
];
//todo; actually test something?
}

return $checks;
}
}
5 changes: 1 addition & 4 deletions cli/ValetPlus/Mailhog.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Mailhog extends AbstractService
/** @var string */
const NGINX_CONFIGURATION_PATH = VALET_HOME_PATH . '/Nginx/mailhog.conf';

/** @var CommandLine */
protected $cli;
/** @var EventDispatcher */
protected $eventDispatcher;

Expand All @@ -42,11 +40,10 @@ public function __construct(
Filesystem $files,
CommandLine $cli
) {
parent::__construct($configuration, $brew, $files);
parent::__construct($configuration, $brew, $files, $cli);

$container = Container::getInstance();
$this->eventDispatcher = $container->get('event_dispatcher');
$this->cli = $cli;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion cli/ValetPlus/Rabbitmq.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public function restart(): void
return;
}

$this->brew->restartService(static::SERVICE_NAME);
$this->brew->stopService(static::SERVICE_NAME);
info("Starting " . static::SERVICE_NAME . "...");
$this->cli->quietlyAsUser('brew services restart ' . static::SERVICE_NAME);
}

/**
Expand Down

0 comments on commit cb71681

Please sign in to comment.