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

Improve retry logic and logs #152

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ up: clone down
docker-compose exec -T app sh -c 'php craft project-config/rebuild'
docker-compose exec -T app sh -c 'php craft up'
docker-compose exec -T app sh -c 'php craft migrate/up'
docker-compose exec -T app sh -c 'php craft queue/run'
docker-compose exec -T app sh -c 'nohup ./queue_listen.sh > queue.log 2>&1 &'

cli:
docker-compose exec -T app sh
Expand Down
11 changes: 9 additions & 2 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ services:
MOCKSERVER_CORS_ALLOW_METHODS: "CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH, TRACE"
networks:
- e2e-network

mockserver-healthcheck:
image: alpine:latest
healthcheck:
test: [ "CMD-SHELL", "curl --fail http://localhost:1080/status" ]
test: ["CMD-SHELL", "curl --fail -XPUT http://mockserver:1080/status || exit 1"]
interval: 5s
timeout: 5s
retries: 3
restart: on-failure
depends_on:
- mockserver
networks:
- e2e-network
entrypoint: ["sh", "-c", "apk add --no-cache curl && while sleep 3600; do :; done"]

networks:
e2e-network:
Expand Down
1 change: 1 addition & 0 deletions e2e/happy-lager-override/config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

// Whether crawlers should be allowed to index pages and following links
'disallowRobots' => !$isProd,
'runQueueAutomatically' => false,

'aliases' => [
'@assetBasePath' => App::env('ASSET_BASE_PATH') ?: "./assets",
Expand Down
8 changes: 8 additions & 0 deletions e2e/happy-lager-override/queue_listen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

while true; do
echo "Starting the queue listen process..."
php craft queue/listen -v
echo "Queue listen completed. Restarting in 30 seconds..."
sleep 1
done
12 changes: 12 additions & 0 deletions src/controllers/job/PostJobRetryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
namespace lilthq\craftliltplugin\controllers\job;

use Craft;
use craft\errors\ElementNotFoundException;
use craft\web\Controller;
use LiltConnectorSDK\ApiException;
use lilthq\craftliltplugin\Craftliltplugin;
use Throwable;
use yii\base\Exception;
use yii\db\StaleObjectException;
use yii\web\Response;

class PostJobRetryController extends Controller
{
/**
* @throws ElementNotFoundException
* @throws Throwable
* @throws ApiException
* @throws StaleObjectException
* @throws Exception
*/
public function actionInvoke(): Response
{
$request = Craft::$app->getRequest();
Expand Down
3 changes: 3 additions & 0 deletions src/modules/AbstractRetryJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ abstract class AbstractRetryJob extends BaseJob
*/
abstract public function canRetry(): bool;

/**
* @return SendJobToConnector|SendTranslationToConnector|FetchJobStatusFromConnector|FetchTranslationFromConnector
*/
abstract public function getRetryJob(): BaseJob;

protected function getCommand(): ?Command
Expand Down
114 changes: 0 additions & 114 deletions src/modules/FetchInstantJobTranslationsFromConnector.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/modules/FetchJobStatusFromConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FetchJobStatusFromConnector extends AbstractRetryJob
public const PRIORITY = 1024;
public const TTR = 60 * 30;

private const RETRY_COUNT = 3;
private const RETRY_COUNT = 10;

/**
* @var int $liltJobId
Expand Down
2 changes: 1 addition & 1 deletion src/modules/FetchTranslationFromConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FetchTranslationFromConnector extends AbstractRetryJob
public const PRIORITY = 2048;
public const TTR = 60 * 30;

private const RETRY_COUNT = 3;
private const RETRY_COUNT = 10;

/**
* @var int $liltJobId
Expand Down
Loading
Loading