add debug logs

This commit is contained in:
Andras Bacsai
2025-01-17 11:38:22 +01:00
parent 95ccf23e9d
commit 973429d2c4
2 changed files with 97 additions and 3 deletions

View File

@@ -21,6 +21,8 @@ class ProductionSeeder extends Seeder
{
public function run(): void
{
echo "Starting ProductionSeeder...\n";
if (isCloud()) {
echo " Running in cloud mode.\n";
} else {
@@ -28,8 +30,11 @@ class ProductionSeeder extends Seeder
}
// Fix for 4.0.0-beta.37
echo "Checking for beta.37 fix...\n";
if (User::find(0) !== null && Team::find(0) !== null) {
echo " Found User 0 and Team 0\n";
if (DB::table('team_user')->where('user_id', 0)->first() === null) {
echo " Creating team_user relationship\n";
DB::table('team_user')->insert([
'user_id' => 0,
'team_id' => 0,
@@ -40,13 +45,17 @@ class ProductionSeeder extends Seeder
}
}
echo "Checking InstanceSettings...\n";
if (InstanceSettings::find(0) == null) {
echo " Creating InstanceSettings\n";
InstanceSettings::create([
'id' => 0,
]);
}
echo "Checking GithubApp...\n";
if (GithubApp::find(0) == null) {
echo " Creating GithubApp\n";
GithubApp::create([
'id' => 0,
'name' => 'Public GitHub',
@@ -56,7 +65,10 @@ class ProductionSeeder extends Seeder
'team_id' => 0,
]);
}
echo "Checking GitlabApp...\n";
if (GitlabApp::find(0) == null) {
echo " Creating GitlabApp\n";
GitlabApp::create([
'id' => 0,
'name' => 'Public GitLab',
@@ -66,9 +78,12 @@ class ProductionSeeder extends Seeder
'team_id' => 0,
]);
}
// Add Coolify host (localhost) as Server if it doesn't exist
if (! isCloud()) {
echo "Setting up localhost server...\n";
if (Server::find(0) == null) {
echo " Creating localhost server\n";
$server_details = [
'id' => 0,
'name' => 'localhost',
@@ -87,12 +102,16 @@ class ProductionSeeder extends Seeder
$server->settings->is_usable = true;
$server->settings->save();
} else {
echo " Updating existing localhost server\n";
$server = Server::find(0);
$server->settings->is_reachable = true;
$server->settings->is_usable = true;
$server->settings->save();
}
echo "Checking StandaloneDocker...\n";
if (StandaloneDocker::find(0) == null) {
echo " Creating StandaloneDocker\n";
StandaloneDocker::create([
'id' => 0,
'name' => 'localhost-coolify',
@@ -103,14 +122,17 @@ class ProductionSeeder extends Seeder
}
if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) {
echo "Setting up SSH keys for non-Windows environment...\n";
$coolify_key_name = '@host.docker.internal';
$ssh_keys_directory = Storage::disk('ssh-keys')->files();
echo ' Found '.count($ssh_keys_directory)." SSH keys\n";
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
$server = Server::find(0);
$found = $server->privateKey;
if (! $found) {
if ($coolify_key) {
echo " Found Coolify SSH key\n";
$user = str($coolify_key)->before('@')->after('id.');
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
PrivateKey::create([
@@ -129,7 +151,10 @@ class ProductionSeeder extends Seeder
}
}
}
if (config('constants.coolify.is_windows_docker_desktop')) {
echo "Setting up Windows Docker Desktop environment...\n";
echo " Creating/updating private key\n";
PrivateKey::updateOrCreate(
[
'id' => 0,
@@ -149,6 +174,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
]
);
if (Server::find(0) == null) {
echo " Creating Windows localhost server\n";
$server_details = [
'id' => 0,
'uuid' => 'coolify-testing-host',
@@ -168,12 +194,16 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$server->settings->is_usable = true;
$server->settings->save();
} else {
echo " Updating Windows localhost server\n";
$server = Server::find(0);
$server->settings->is_reachable = true;
$server->settings->is_usable = true;
$server->settings->save();
}
echo "Checking Windows StandaloneDocker...\n";
if (StandaloneDocker::find(0) == null) {
echo " Creating Windows StandaloneDocker\n";
StandaloneDocker::create([
'id' => 0,
'name' => 'localhost-coolify',
@@ -183,11 +213,19 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
}
}
echo "Getting public IPs...\n";
get_public_ips();
echo "Running additional seeders...\n";
echo " Running OauthSettingSeeder\n";
$this->call(OauthSettingSeeder::class);
echo " Running PopulateSshKeysDirectorySeeder\n";
$this->call(PopulateSshKeysDirectorySeeder::class);
echo " Running SentinelSeeder\n";
$this->call(SentinelSeeder::class);
// $this->call(RootUserSeeder::class);
echo " Running RootUserSeeder\n";
$this->call(RootUserSeeder::class);
echo "ProductionSeeder complete!\n";
}
}