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');
|
$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
|
public function handle(): void
|
||||||
{
|
{
|
||||||
if ($this->platform === PlatformEnum::LEMMY) {
|
if ($this->platform === PlatformEnum::LEMMY) {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,12 @@ elif [ "$1" = "queue" ]; then
|
||||||
echo "All migrations completed."
|
echo "All migrations completed."
|
||||||
echo "Waiting for database to stabilize..."
|
echo "Waiting for database to stabilize..."
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
|
echo "Dispatching initial sync job..."
|
||||||
|
php artisan tinker --execute="App\\Jobs\\SyncChannelPostsJob::dispatchForLemmy();"
|
||||||
|
|
||||||
|
echo "Fetching initial articles..."
|
||||||
|
php artisan article:refresh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Execute the command based on the argument
|
# Execute the command based on the argument
|
||||||
|
|
@ -54,7 +60,7 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
"queue")
|
"queue")
|
||||||
echo "Starting queue worker..."
|
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}"
|
echo "Usage: $0 {web|queue}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue