fix: enable cron daemon in Dockerfile, speed up sync interval to every 5 minutes and add opportunistic auto-sync check
This commit is contained in:
+6
-3
@@ -41,12 +41,15 @@ COPY --from=node_builder /app/public/build /app/public/build
|
|||||||
RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
|
RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
# Zorg voor de juiste opslagpermissies en database bestand
|
# Zorg voor de juiste opslagpermissies en database bestand
|
||||||
RUN mkdir -p /app/storage /app/bootstrap/cache /app/database \
|
RUN mkdir -p /app/storage /app/bootstrap/cache /app/database /app/storage/logs \
|
||||||
&& touch /app/database/database.sqlite \
|
&& touch /app/database/database.sqlite /app/storage/logs/cron.log \
|
||||||
&& chown -R www-data:www-data /app/storage /app/bootstrap/cache /app/database \
|
&& chown -R www-data:www-data /app/storage /app/bootstrap/cache /app/database \
|
||||||
&& chmod -R 775 /app/storage /app/bootstrap/cache /app/database
|
&& chmod -R 775 /app/storage /app/bootstrap/cache /app/database
|
||||||
|
|
||||||
|
# Configureer crontab voor Laravel Scheduler (draait elke minuut php artisan schedule:run)
|
||||||
|
RUN echo "* * * * * cd /app && php artisan schedule:run >> /app/storage/logs/cron.log 2>&1" > /etc/crontabs/root
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["sh", "-c", "php artisan storage:link && mkdir -p /app/database /app/storage/framework/cache /app/storage/framework/sessions /app/storage/framework/views /app/storage/logs && touch /app/database/database.sqlite && chmod -R 777 /app/database /app/storage && php artisan migrate --force && php artisan db:seed --force && frankenphp run --config /etc/caddy/Caddyfile"]
|
CMD ["sh", "-c", "php artisan storage:link && mkdir -p /app/database /app/storage/framework/cache /app/storage/framework/sessions /app/storage/framework/views /app/storage/logs && touch /app/database/database.sqlite /app/storage/logs/cron.log && chmod -R 777 /app/database /app/storage && php artisan migrate --force && php artisan db:seed --force && crond -b -l 2 && frankenphp run --config /etc/caddy/Caddyfile"]
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use App\Services\MakerWorldService;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class MakerWorldController extends Controller
|
class MakerWorldController extends Controller
|
||||||
@@ -31,6 +32,22 @@ class MakerWorldController extends Controller
|
|||||||
$apiCollections = [];
|
$apiCollections = [];
|
||||||
|
|
||||||
if ($tab === 'collections') {
|
if ($tab === 'collections') {
|
||||||
|
// Check of actieve collecties toe zijn aan synchronisatie (> 5 minuten geleden of nog nooit gesynchroniseerd)
|
||||||
|
$dueCollections = MakerWorldCollection::where('is_active_sync', true)
|
||||||
|
->where(function ($q) {
|
||||||
|
$q->whereNull('last_synced_at')
|
||||||
|
->orWhere('last_synced_at', '<=', now()->subMinutes(5));
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($dueCollections as $dueCol) {
|
||||||
|
try {
|
||||||
|
$this->makerWorld->syncCollection($dueCol);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning("Auto-sync error for collection #{$dueCol->id}: {$e->getMessage()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($isAuthenticated) {
|
if ($isAuthenticated) {
|
||||||
$apiCollections = $this->makerWorld->getFavoritesCollections();
|
$apiCollections = $this->makerWorld->getFavoritesCollections();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,8 +304,18 @@
|
|||||||
<div class="text-[11px] text-slate-400 space-y-1">
|
<div class="text-[11px] text-slate-400 space-y-1">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span>Laatste controle:</span>
|
<span>Laatste controle:</span>
|
||||||
<span class="font-mono text-slate-300">
|
<span class="font-mono text-slate-300 font-bold">
|
||||||
{{ $collection->last_synced_at ? $collection->last_synced_at->diffForHumans() : 'Nog niet' }}
|
{{ $collection->last_synced_at ? $collection->last_synced_at->diffForHumans() : 'Nog niet' }}
|
||||||
|
@if($collection->last_synced_at)
|
||||||
|
<span class="text-[10px] text-slate-500 font-normal">({{ $collection->last_synced_at->format('H:i:s') }})</span>
|
||||||
|
@endif
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between text-[10px]">
|
||||||
|
<span class="text-slate-500">Auto-sync interval:</span>
|
||||||
|
<span class="font-bold text-emerald-400 flex items-center space-x-1">
|
||||||
|
<span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span>
|
||||||
|
<span>Iedere 5 min</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@if($collection->last_sync_message)
|
@if($collection->last_sync_message)
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ Artisan::command('inspire', function () {
|
|||||||
$this->comment(Inspiring::quote());
|
$this->comment(Inspiring::quote());
|
||||||
})->purpose('Display an inspiring quote');
|
})->purpose('Display an inspiring quote');
|
||||||
|
|
||||||
// Automatische MakerWorld Collecties Synchronisatie iedere 10 minuten
|
// Automatische MakerWorld Collecties Synchronisatie iedere 5 minuten
|
||||||
Schedule::command('app:sync-makerworld-collections')
|
Schedule::command('app:sync-makerworld-collections')
|
||||||
->everyTenMinutes()
|
->everyFiveMinutes()
|
||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->runInBackground();
|
->runInBackground();
|
||||||
|
|||||||
Reference in New Issue
Block a user