Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

protonemedia/eddy-server-management

507 stars
2 code files
View protonemedia/eddy-server-management on GitHub

app/Notifications/ServerProvisioningFailed.php

Open in GitHub
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Markdown;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
 
class ServerProvisioningFailed extends Notification implements ShouldQueue
{
use Queueable;
 
public function __construct(
public string $serverName,
public string $output = '',
public string $errorMessage = '',
) {
//
}
 
public function via(object $notifiable): array
{
return ['mail'];
}
 
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line(__("The server ':name' failed to provision. We've deleted it for you, but you might have to manually remove it from your provider.", ['name' => $this->serverName]))
->when($this->output, function (MailMessage $message) {
$message
->line(__("Here you'll find the 10 last lines of the task that failed:"))
->line(Markdown::parse("```{$this->output}```"));
})
->when($this->errorMessage, function (MailMessage $message) {
$message
->line(__('This is the error message we received:'))
->line(Markdown::parse("```{$this->errorMessage}```"));
});
}
}

app/Jobs/CleanupFailedServerProvisioning.php

Open in GitHub
use App\Models\Server;
use App\Models\Task;
use App\Notifications\ServerProvisioningFailed;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
 
class CleanupFailedServerProvisioning implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
public function __construct(
public Server $server,
public ?Task $task = null,
public ?string $errorMessage = null,
) {
//
}
 
public function handle(): void
{
rescue(fn () => $this->task?->updateOutputWithoutCallbacks(), report: false);
 
$this->server->createdByUser?->notify(
new ServerProvisioningFailed(
$this->server->name,
$this->task?->tailOutput() ?: '',
$this->errorMessage ?: ''
)
);
 
$this->server->delete();
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.