This commit is contained in:
102
Program.cs
102
Program.cs
@@ -9,8 +9,9 @@ Console.WriteLine($"AyaNova server launcher {AyaNovaVersion.VersionString}");
|
|||||||
//Locate the ayanova executable folder as the basis point for all other paths later
|
//Locate the ayanova executable folder as the basis point for all other paths later
|
||||||
var AyaNovaProgramFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), ".."));
|
var AyaNovaProgramFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), ".."));
|
||||||
|
|
||||||
|
#if(DEBUG)
|
||||||
AyaNovaProgramFolder = @"c:\Program Files\ayanova\";
|
AyaNovaProgramFolder = @"c:\Program Files\ayanova\";
|
||||||
|
#endif
|
||||||
//read in the config.json file to get it's current values
|
//read in the config.json file to get it's current values
|
||||||
var ConfigFile = Path.Combine(AyaNovaProgramFolder, "config.json");
|
var ConfigFile = Path.Combine(AyaNovaProgramFolder, "config.json");
|
||||||
if (!File.Exists(ConfigFile))
|
if (!File.Exists(ConfigFile))
|
||||||
@@ -44,29 +45,33 @@ catch (Exception ex)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"DataPath resolved to: {DataPath}");
|
||||||
|
Console.WriteLine($"AyaNovaProgramFolder resolved to: {AyaNovaProgramFolder}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================== LAUNCH POSTGRES SERVER ==================
|
//================== LAUNCH POSTGRES SERVER ==================
|
||||||
//https://notepad.onghu.com/2021/portable-postgresql-on-windows-without-installation/
|
//https://notepad.onghu.com/2021/portable-postgresql-on-windows-without-installation/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ProcessStartInfo PGStartInfo = new ProcessStartInfo();
|
ProcessStartInfo PGStartInfo = new ProcessStartInfo();
|
||||||
//PGStartInfo.EnvironmentVariables["PGDATA"] = Path.Combine(DataPath, "database");
|
PGStartInfo.EnvironmentVariables["PGDATA"] = Path.Combine(DataPath, "database");
|
||||||
////PGStartInfo.EnvironmentVariables["PGDATABASE"] = "AyaNova";
|
//PGStartInfo.EnvironmentVariables["PGDATABASE"] = "AyaNova";
|
||||||
//PGStartInfo.EnvironmentVariables["PGUSER"] = "postgres";
|
PGStartInfo.EnvironmentVariables["PGUSER"] = "postgres";
|
||||||
//PGStartInfo.EnvironmentVariables["PGPORT"] = "5432";
|
PGStartInfo.EnvironmentVariables["PGPORT"] = "5432";
|
||||||
//PGStartInfo.EnvironmentVariables["PGLOCALEDIR"] = Path.Combine(AyaNovaProgramFolder, "local-postgres", "share", "locale");
|
PGStartInfo.EnvironmentVariables["PGLOCALEDIR"] = Path.Combine(AyaNovaProgramFolder, "local-postgres", "share", "locale");
|
||||||
//PGStartInfo.EnvironmentVariables["PGLOGS "] = Path.Combine(DataPath, "logs");
|
PGStartInfo.EnvironmentVariables["PGLOGS "] = Path.Combine(DataPath, "logs");
|
||||||
|
|
||||||
//ARGUMENTS DOC: https://www.postgresql.org/docs/11/app-postgres.html
|
//ARGUMENTS DOC: https://www.postgresql.org/docs/11/app-postgres.html
|
||||||
PGStartInfo.Arguments = $"-D {Path.Combine(DataPath, "database")} -o \"-p 5432\" -l {Path.Combine(DataPath, "logs","postgres.log")} start";
|
//PGStartInfo.Arguments = $"-D {Path.Combine(DataPath, "database")} -o \"-p 5432\" -l {Path.Combine(DataPath, "logs","postgres.log")} start";
|
||||||
|
PGStartInfo.Arguments = "start";
|
||||||
PGStartInfo.FileName = "pg_ctl.exe";
|
PGStartInfo.FileName = "pg_ctl.exe";
|
||||||
//PGStartInfo.WorkingDirectory = Path.Combine(DataPath, "database");
|
//PGStartInfo.WorkingDirectory = Path.Combine(DataPath, "database");
|
||||||
PGStartInfo.WorkingDirectory = Path.Combine(AyaNovaProgramFolder, "local-postgres", "bin");
|
PGStartInfo.WorkingDirectory = Path.Combine(AyaNovaProgramFolder, "local-postgres", "bin");
|
||||||
|
|
||||||
PGStartInfo.UseShellExecute = true;
|
PGStartInfo.UseShellExecute = false;
|
||||||
|
|
||||||
|
//Console.WriteLine($"PGStartInfo environment: {string.Join(",",PGStartInfo.EnvironmentVariables.Values.GetEnumerator())}");
|
||||||
|
|
||||||
var PGProcess = Process.Start(PGStartInfo);
|
var PGProcess = Process.Start(PGStartInfo);
|
||||||
|
|
||||||
/*"-D C:\ProgramData\ayanova\database -p 5432 -l C:\ProgramData\ayanova\logs start"
|
/*"-D C:\ProgramData\ayanova\database -p 5432 -l C:\ProgramData\ayanova\logs start"
|
||||||
@@ -92,7 +97,7 @@ set AYANOVA_DATA_PATH=%~dp0data
|
|||||||
ProcessStartInfo ServerStartInfo = new ProcessStartInfo();
|
ProcessStartInfo ServerStartInfo = new ProcessStartInfo();
|
||||||
ServerStartInfo.FileName = "AyaNova.exe";
|
ServerStartInfo.FileName = "AyaNova.exe";
|
||||||
ServerStartInfo.WorkingDirectory = AyaNovaProgramFolder;
|
ServerStartInfo.WorkingDirectory = AyaNovaProgramFolder;
|
||||||
ServerStartInfo.UseShellExecute = true;
|
ServerStartInfo.UseShellExecute = false;
|
||||||
var ServerProcess = Process.Start(ServerStartInfo);
|
var ServerProcess = Process.Start(ServerStartInfo);
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +115,78 @@ if (PGProcess != null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ####################### OLD SHIT ################################
|
||||||
|
|
||||||
|
//This works but launches three windows
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
//================== LAUNCH POSTGRES SERVER ==================
|
||||||
|
//https://notepad.onghu.com/2021/portable-postgresql-on-windows-without-installation/
|
||||||
|
|
||||||
|
ProcessStartInfo PGStartInfo = new ProcessStartInfo();
|
||||||
|
//PGStartInfo.EnvironmentVariables["PGDATA"] = Path.Combine(DataPath, "database");
|
||||||
|
////PGStartInfo.EnvironmentVariables["PGDATABASE"] = "AyaNova";
|
||||||
|
//PGStartInfo.EnvironmentVariables["PGUSER"] = "postgres";
|
||||||
|
//PGStartInfo.EnvironmentVariables["PGPORT"] = "5432";
|
||||||
|
//PGStartInfo.EnvironmentVariables["PGLOCALEDIR"] = Path.Combine(AyaNovaProgramFolder, "local-postgres", "share", "locale");
|
||||||
|
//PGStartInfo.EnvironmentVariables["PGLOGS "] = Path.Combine(DataPath, "logs");
|
||||||
|
|
||||||
|
//ARGUMENTS DOC: https://www.postgresql.org/docs/11/app-postgres.html
|
||||||
|
PGStartInfo.Arguments = $"-D {Path.Combine(DataPath, "database")} -o \"-p 5432\" -l {Path.Combine(DataPath, "logs","postgres.log")} start";
|
||||||
|
PGStartInfo.FileName = "pg_ctl.exe";
|
||||||
|
//PGStartInfo.WorkingDirectory = Path.Combine(DataPath, "database");
|
||||||
|
PGStartInfo.WorkingDirectory = Path.Combine(AyaNovaProgramFolder, "local-postgres", "bin");
|
||||||
|
|
||||||
|
PGStartInfo.UseShellExecute = true;
|
||||||
|
var PGProcess = Process.Start(PGStartInfo);
|
||||||
|
|
||||||
|
// "-D C:\ProgramData\ayanova\database -p 5432 -l C:\ProgramData\ayanova\logs start"
|
||||||
|
// old batch file settings required for postgres
|
||||||
|
// SET PATH="%~dp0postgres\bin";%PATH%
|
||||||
|
// SET PGDATA=%~dp0data\database
|
||||||
|
// SET PGDATABASE=AyaNova
|
||||||
|
// SET PGUSER=postgres
|
||||||
|
// SET PGPORT=5432
|
||||||
|
// SET PGLOCALEDIR=%~dp0postgres\share\locale
|
||||||
|
// set AYANOVA_USE_URLS=http://*:7575;
|
||||||
|
// set AYANOVA_DB_CONNECTION=Server=localhost;Username=postgres;Password=mypasswordforpostgres;Database=AyaNova;
|
||||||
|
// set AYANOVA_DEFAULT_TRANSLATION=en
|
||||||
|
// set AYANOVA_BACKUP_PG_DUMP_PATH=%~dp0postgres\bin\
|
||||||
|
// set AYANOVA_DATA_PATH=%~dp0data
|
||||||
|
// "%~dp0\postgres\bin\pg_ctl" -D "%~dp0/data/database" -l %~dp0data\logs\postgreslog start
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================== LAUNCH AYANOVA SERVER ==================
|
||||||
|
//Go UP one folder from the current launcher folder which should *always* be contained within the AyaNova.exe containing folder if it was installed
|
||||||
|
|
||||||
|
ProcessStartInfo ServerStartInfo = new ProcessStartInfo();
|
||||||
|
ServerStartInfo.FileName = "AyaNova.exe";
|
||||||
|
ServerStartInfo.WorkingDirectory = AyaNovaProgramFolder;
|
||||||
|
ServerStartInfo.UseShellExecute = true;
|
||||||
|
var ServerProcess = Process.Start(ServerStartInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================== WAIT FOR SHUTDOWN ================
|
||||||
|
Console.WriteLine("Waiting for server to exit; do not close this window");
|
||||||
|
if (ServerProcess != null)
|
||||||
|
ServerProcess.WaitForExit();
|
||||||
|
|
||||||
|
//shutdown postgres
|
||||||
|
if (PGProcess != null)
|
||||||
|
{
|
||||||
|
PGProcess.CloseMainWindow();
|
||||||
|
PGProcess.WaitForExit();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//############################################################################
|
||||||
|
//this was original ctr.-c shutdown from one window concept
|
||||||
|
|
||||||
|
|
||||||
// Console.WriteLine("#############################################");
|
// Console.WriteLine("#############################################");
|
||||||
|
|||||||
Reference in New Issue
Block a user