revert: run emoji cloud migration inline, not via queued job

Keep the migration running the upload inline (Artisan::call), not dispatched
to the queue. The local emoji files live on the web container's storage where
migrations run; a queued Horizon worker may not share that storage in future
(web and horizon storage decoupled), which would make a queued job a no-op.

Reverts the EmojiMigrateToCloudPipeline job approach.
feat/emoji-cloud-storage-v2
Your Name 3 weeks ago
parent 808a03117d
commit e5c119d35c

@ -1,60 +0,0 @@
<?php
namespace App\Jobs\MediaPipeline;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
class EmojiMigrateToCloudPipeline implements ShouldBeUnique, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Bulk emoji upload can take a while; allow up to an hour.
*/
public $timeout = 3600;
/**
* Do not auto-retry a long bulk transfer. It is safe to re-dispatch
* manually, but automatic retries would re-run the whole upload.
*/
public $tries = 1;
/**
* Only one migration job should be queued/running at a time.
*/
public $uniqueFor = 3600;
public function uniqueId(): string
{
return 'emoji-migrate-to-cloud';
}
public function handle(): void
{
// Guard again at run time in case cloud storage was toggled off between
// dispatch and execution.
$cloudEnabled = (bool) config('pixelfed.cloud_storage') || (bool) config_cache('pixelfed.cloud_storage');
if (! $cloudEnabled) {
Log::info('EmojiMigrateToCloudPipeline: cloud storage not enabled, skipping.');
return;
}
Log::info('EmojiMigrateToCloudPipeline: starting emoji migration to cloud.');
Artisan::call('admin:EmojiMoveStorageLocalToCloud', [
'--force' => true,
'--concurrency' => 100,
]);
Log::info('EmojiMigrateToCloudPipeline: finished. '.trim(Artisan::output()));
}
}

@ -1,7 +1,7 @@
<?php
use App\Jobs\MediaPipeline\EmojiMigrateToCloudPipeline;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Artisan;
return new class extends Migration
{
@ -9,24 +9,26 @@ return new class extends Migration
* Run the migrations.
*
* When cloud storage is enabled, custom emoji URLs resolve to the cloud
* disk. Existing emoji may still only exist locally, so migrate them to
* cloud to avoid a window where their URLs 404.
* disk. Existing emoji may still only exist locally, so move them all to
* cloud now (in one pass) to avoid a window where their URLs 404.
*
* The upload is potentially large and network-bound, so we dispatch it to
* the queue and return immediately rather than blocking the upgrade. The
* work runs in the background on Horizon. No-op on local-only instances.
* Run inline (not queued) because the local emoji files live on the web
* container's storage, which is where migrations run; a queued worker may
* not share that storage. This is a no-op on local-only instances.
*/
public function up(): void
{
// Consider cloud enabled if either the live config or the (possibly
// cached) config_cache value says so; the job guards again at runtime.
// cached) config_cache value says so; the command guards again anyway.
$cloudEnabled = (bool) config('pixelfed.cloud_storage') || (bool) config_cache('pixelfed.cloud_storage');
if (! $cloudEnabled) {
return;
}
EmojiMigrateToCloudPipeline::dispatch()->onQueue('mmo');
Artisan::call('admin:EmojiMoveStorageLocalToCloud', [
'--force' => true,
]);
}
/**

Loading…
Cancel
Save