mixpost icon indicating copy to clipboard operation
mixpost copied to clipboard

Add database queue docs

Open cweagans opened this issue 1 year ago • 7 comments

Detailed description

Mixpost works great with the database queue - no Redis installation required. Adding some docs for this would make it accessible to people like me running Mixpost on cheap shared hosting (Dreamhost, in my case)

.env:

QUEUE_CONNECTION=database

crontab:

* * * * * cd /path/to/installation && php artisan queue:work --queue=publish-post --once --max-time=60 >> /dev/null 2>&1
* * * * * cd /path/to/installation && php artisan queue:work --max-time=60 >> /dev/null 2>&1

I have it set up to run one publish-post job per minute to make sure I'm not running expensive jobs frequently on my shared hosting account (they frown on that), but that's really the only difference.

cweagans avatar Nov 21 '23 17:11 cweagans

So far, there's one thing that is somewhat broken actually: the status page in the admin console (Pro) shows an internal error whenever I try to load it. It looks like there's some hardcoded call to Redis (or maybe Horizon?) on that page.

cweagans avatar Nov 21 '23 18:11 cweagans

Yeah, confirmed -- if I comment out the 'horizon_status' => resolve(HorizonStatus::class)->get(), line, the status page loads again.

cweagans avatar Nov 21 '23 18:11 cweagans

Looks like there is a problem running the scheduler or something. Gotta transition to working on other things now, but even though I'm running the schedule:run command every minute, the status page reports that it hasn't been run for many hours. Also, the mixpost-redis queue config probably needs switched to the database settings too. Also, there is a horizon:snapshot command in the scheduler that probably needs disabled -- I'm not super familiar with Horizon, so I'll have to figure that out later.

cweagans avatar Nov 21 '23 18:11 cweagans

Looks like another thing that needs to happen is to change WorkspaceOwnedScope to ignore the scope if it's running in a console (app()->isRunningInConsole()). Otherwise, php artisan mixpost:check-and-refresh-account-token returns this error:

In WorkspaceOwnedScope.php line 17:

  Attempt to read property "id" on null

Ideally, the status page would show some database queue information instead of Horizon if the application is configured to use a database queue.

cweagans avatar Nov 22 '23 21:11 cweagans

I also changed the schedule() method in app/Console/Kernel.php like so:

        // REMOVED: we're not using Horizon on shared hosting.
        //$schedule->command('horizon:snapshot')->everyFiveMinutes();
        $schedule->command('queue:prune-batches')->daily();
        $schedule->command('queue:work --max-time=60 --stop-when-empty')->everyFiveMinutes();
        $schedule->command('queue:work --queue=publish-post --once --max-time=60 --stop-when-empty')->everyTenMinutes();

cweagans avatar Nov 27 '23 21:11 cweagans

@cweagans Have you tested this, does it work without problems?

lao9s avatar Dec 02 '23 11:12 lao9s

I'm running it in production right now on cheap shared hosting (Dreamhost). Seems to be working. I've been keeping an eye out for log entries that might indicate that it's not, but so far, no surprises.

cweagans avatar Dec 02 '23 18:12 cweagans