Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add register modules sequence command. #162

Merged
merged 1 commit into from
Apr 30, 2024
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
1 change: 1 addition & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN composer config --no-plugins allow-plugins.spiral/composer-publish-plugin fa
RUN composer install --no-dev

WORKDIR /app
RUN mkdir /app/runtime/configs -p
RUN php app.php configure

EXPOSE 8082/tcp
Expand Down
4 changes: 1 addition & 3 deletions .rr-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ metrics:
server:
command: 'php app.php'
relay: pipes
env:
- MODE: roadrunner
on_init:
command: "php app.php configure"
command: "php app.php register:modules"

logs:
level: ${RR_LOG_LEVEL:-info}
Expand Down
4 changes: 1 addition & 3 deletions .rr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ metrics:
server:
command: 'php app.php'
relay: pipes
env:
- MODE: roadrunner
on_init:
command: "php app.php configure"
command: "php app.php register:modules"

logs:
level: info
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
build:
if [ ! -d "runtime" ]; then \
mkdir runtime/configs -p; \
chmod 0777 -R runtime; \
fi
chmod +x bin/get-binaries.sh; \
if [ ! -f "bin/centrifugo" ]; then \
cd bin; \
./get-binaries.sh; \
cd ../; \
fi
if [ ! -f "rr" ]; then \
vendor/bin/rr get;\
fi
if [ ! -d "vendor" ]; then \
composer i --ignore-platform-reqs; \
fi
docker compose up --no-start;

start:
Expand Down
5 changes: 3 additions & 2 deletions app/modules/Metrics/Application/MetricsBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Modules\Metrics\Application;

use App\Application\Mode;
use App\Interfaces\Console\RegisterModulesCommand;
use Cycle\ORM\FactoryInterface;
use Modules\Metrics\Infrastructure\RoadRunner\Collector;
use Spiral\Boot\Bootloader\Bootloader;
Expand Down Expand Up @@ -54,7 +54,8 @@ public function defineSingletons(): array

public function init(ConsoleBootloader $console): void
{
$console->addConfigureSequence(
$console->addSequence(
name: RegisterModulesCommand::SEQUENCE,
sequence: 'metrics:declare',
header: 'Declare metrics',
);
Expand Down
15 changes: 7 additions & 8 deletions app/modules/Projects/Application/ProjectBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Modules\Projects\Application;

use App\Application\Mode;
use App\Interfaces\Console\RegisterModulesCommand;
use Modules\Projects\Domain\ProjectFactoryInterface;
use Modules\Projects\Domain\ProjectLocatorInterface;
use Spiral\Boot\Bootloader\Bootloader;
Expand Down Expand Up @@ -40,13 +40,12 @@ public function defineSingletons(): array
];
}

public function init(ConsoleBootloader $console, Mode $mode): void
public function init(ConsoleBootloader $console): void
{
if ($mode->insideRoadRunner()) {
$console->addConfigureSequence(
sequence: 'projects:register',
header: 'Register all projects in the system',
);
}
$console->addSequence(
name: RegisterModulesCommand::SEQUENCE,
sequence: 'projects:register',
header: 'Register all projects in the system',
);
}
}
6 changes: 3 additions & 3 deletions app/modules/Webhooks/Application/WebhooksBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Modules\Webhooks\Application;

use App\Application\Mode;
use App\Interfaces\Console\RegisterModulesCommand;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use Modules\Metrics\Application\CollectorRegistryInterface;
Expand Down Expand Up @@ -92,9 +92,9 @@ public function defineSingletons(): array
public function init(
ConsoleBootloader $console,
CollectorRegistryInterface $collectorRegistry,
Mode $mode,
): void {
$console->addConfigureSequence(
$console->addSequence(
name: RegisterModulesCommand::SEQUENCE,
sequence: 'webhooks:register',
header: 'Register webhooks from configuration',
);
Expand Down
31 changes: 0 additions & 31 deletions app/src/Application/Mode.php

This file was deleted.

29 changes: 29 additions & 0 deletions app/src/Interfaces/Console/RegisterModulesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace App\Interfaces\Console;

use App\Application\Commands\HandleReceivedEvent;
use Psr\Container\ContainerInterface;
use Spiral\Console\Attribute\AsCommand;
use Spiral\Console\Command\SequenceCommand;
use Spiral\Console\Config\ConsoleConfig;
use Spiral\Cqrs\CommandBusInterface;

#[AsCommand(
name: 'register:modules',
description: 'Register modules',
)]
final class RegisterModulesCommand extends SequenceCommand
{
public const SEQUENCE = 'register:modules';

public function __invoke(ConsoleConfig $config, ContainerInterface $container): int
{
$this->info('Register buggregator modules...');
$this->newLine();

return $this->runSequence($config->getSequence(self::SEQUENCE), $container);
}
}
33 changes: 0 additions & 33 deletions app/src/Interfaces/Console/TestCommand.php

This file was deleted.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"rector/rector": "^1.0",
"sentry/sentry": "^4.7",
"spiral-packages/database-seeder": "^3.1",
"spiral/roadrunner-cli": "^2.6",
"spiral/testing": "^2.6",
"vimeo/psalm": "^5.16"
},
Expand Down
Loading
Loading