Run commands at boot
This commit is contained in:
parent
7653797e71
commit
66f0c7c2d5
2 changed files with 19 additions and 1 deletions
|
|
@ -22,6 +22,18 @@ public function __construct(
|
|||
$this->onQueue('lemmy-posts');
|
||||
}
|
||||
|
||||
public static function dispatchForLemmy(): void
|
||||
{
|
||||
$communityId = config('lemmy.community_id');
|
||||
$communityName = config('lemmy.community');
|
||||
|
||||
if ($communityId && $communityName) {
|
||||
self::dispatch(PlatformEnum::LEMMY, (string) $communityId, $communityName);
|
||||
} else {
|
||||
logger()->warning('Cannot dispatch Lemmy sync job: missing community configuration');
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if ($this->platform === PlatformEnum::LEMMY) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ elif [ "$1" = "queue" ]; then
|
|||
echo "All migrations completed."
|
||||
echo "Waiting for database to stabilize..."
|
||||
sleep 5
|
||||
|
||||
echo "Dispatching initial sync job..."
|
||||
php artisan tinker --execute="App\\Jobs\\SyncChannelPostsJob::dispatchForLemmy();"
|
||||
|
||||
echo "Fetching initial articles..."
|
||||
php artisan article:refresh
|
||||
fi
|
||||
|
||||
# Execute the command based on the argument
|
||||
|
|
@ -54,7 +60,7 @@ case "$1" in
|
|||
;;
|
||||
"queue")
|
||||
echo "Starting queue worker..."
|
||||
exec php artisan queue:work --tries=3
|
||||
exec php artisan queue:work --tries=3 --queue=lemmy-posts,default
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {web|queue}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue