mixpost
mixpost copied to clipboard
Add database queue docs
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.
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.
Yeah, confirmed -- if I comment out the 'horizon_status' => resolve(HorizonStatus::class)->get(),
line, the status page loads again.
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.
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.
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 Have you tested this, does it work without problems?
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.