Skip to content

Commit

Permalink
Merge pull request #8 from vitodeploy/fix-realtime-update
Browse files Browse the repository at this point in the history
fix realtime update
  • Loading branch information
saeedvaziry authored Aug 11, 2023
2 parents c87e552 + a8f8d97 commit ec47c9c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=pusher
CACHE_DRIVER=array
CACHE_DRIVER=redis
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=default
SESSION_DRIVER=database
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
Expand Down
27 changes: 17 additions & 10 deletions app/Jobs/Installation/ContinueInstallation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,31 @@ class ContinueInstallation extends InstallationJob

protected int $attempts;

public function __construct(Server $server)
public function __construct(Server $server, int $attempts = 0)
{
$this->server = $server;
$this->attempts = 2;
$this->attempts = $attempts;
}

public function handle(): void
{
if ($this->server->provider()->isRunning()) {
$this->server->install();
} else {
$this->attempts--;
if ($this->attempts > 0) {
sleep(120);
$this->handle();
} else {
event(new Broadcast('install-server-failed', $this->server->toArray()));
}
return;
}

if ($this->attempts >= 2) {
$this->server->update([
'status' => 'installation_failed',
]);
event(
new Broadcast('install-server-failed', [
'server' => $this->server,
])
);
return;
}

dispatch(new self($this->server, $this->attempts++))->delay(now()->addMinute());
}
}
3 changes: 1 addition & 2 deletions app/Jobs/Installation/InstallationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

use App\Jobs\LongJob;
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;

abstract class InstallationJob implements ShouldQueue, ShouldBeUnique
abstract class InstallationJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use LongJob;
Expand Down
3 changes: 3 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ if ! echo "${V_NGINX_CONFIG}" | tee /etc/nginx/nginx.conf; then
fi
service nginx start

# redis
apt install redis-server -y

# php
export V_PHP_VERSION="8.1"
add-apt-repository ppa:ondrej/php -y
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
"build": "vite build",
"queue:listen": "php artisan queue:listen --timeout=600 --queue=default,ssh,ssh-long"
},
"devDependencies": {
"@ryangjchandler/alpine-clipboard": "^2.2.0",
Expand Down

0 comments on commit ec47c9c

Please sign in to comment.