Compare commits
3 Commits
2231ba9296
...
781858a905
Author | SHA1 | Date | |
---|---|---|---|
781858a905 | |||
03d4c243a4 | |||
53d58c31a7 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
**/vendor/
|
**/vendor/
|
||||||
**/*.env
|
**/*.env
|
||||||
**/*.lock
|
**/*.lock
|
||||||
|
**/.idea/
|
||||||
|
**/logs/
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
FROM php:cli
|
FROM php:cli
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -yq --no-install-recommends cron && rm -r /var/lib/apt/lists/* \
|
RUN apt-get update && apt-get install -yq --no-install-recommends cron && rm -r /var/lib/apt/lists/*
|
||||||
&& docker-php-ext-install pdo_mysql
|
RUN docker-php-ext-install pdo_mysql
|
||||||
|
|
||||||
CMD [ "cron", "-f", "-L", "15" ]
|
CMD [ "cron", "-f", "-L", "15" ]
|
||||||
|
#ENTRYPOINT [ "/app/bin/console" ]
|
||||||
|
#CMD [ "/app/bin/console", "watch" ]
|
||||||
|
@ -15,7 +15,7 @@ use ProVM\Service\Remote;
|
|||||||
)]
|
)]
|
||||||
class UpdateIp extends Command
|
class UpdateIp extends Command
|
||||||
{
|
{
|
||||||
public function __construct(protected Remote $service, protected LoggerInterface $logger, ?string $name = 'update')
|
public function __construct(protected Remote $service, protected LoggerInterface $logger, string $name = 'update')
|
||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use function Safe\shell_exec;
|
||||||
|
|
||||||
#[AsCommand(
|
#[AsCommand(
|
||||||
name: 'watch',
|
name: 'watch',
|
||||||
@ -14,7 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
)]
|
)]
|
||||||
class Watch extends Command
|
class Watch extends Command
|
||||||
{
|
{
|
||||||
public function __construct(protected string $period, ?string $name = 'watch')
|
public function __construct(protected string $period, string $name = 'watch')
|
||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@ use function Safe\json_decode;
|
|||||||
|
|
||||||
class Ipify
|
class Ipify
|
||||||
{
|
{
|
||||||
public function __construct(protected ClientInterface $client, protected LoggerInterface $logger) {}
|
public function __construct(protected ClientInterface $client, protected string $uri, protected LoggerInterface $logger) {}
|
||||||
|
|
||||||
public function get(): string
|
public function get(): string
|
||||||
{
|
{
|
||||||
$this->logger->debug('Getting IP');
|
$this->logger->debug('Getting IP');
|
||||||
$response = $this->client->get('?format=json');
|
$response = $this->client->get('?format=json');
|
||||||
if (round($response->getCode() / 100, 0) !== 2) {
|
if (round($response->getStatusCode() / 100, 0) != 2) {
|
||||||
throw new Exception("Could not connect to '{$this->client->base_uri}'");
|
throw new Exception("Could not connect to '{$this->uri}'");
|
||||||
}
|
}
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$json = json_decode($body->getContents());
|
$json = json_decode($body->getContents());
|
||||||
|
@ -28,6 +28,7 @@ return [
|
|||||||
ProVM\Service\Ipify::class => function(ContainerInterface $container) {
|
ProVM\Service\Ipify::class => function(ContainerInterface $container) {
|
||||||
return new ProVM\Service\Ipify(
|
return new ProVM\Service\Ipify(
|
||||||
$container->get(Psr\Http\Client\ClientInterface::class),
|
$container->get(Psr\Http\Client\ClientInterface::class),
|
||||||
|
$container->get('uri'),
|
||||||
$container->get(Psr\Log\LoggerInterface::class)
|
$container->get(Psr\Log\LoggerInterface::class)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user