This commit is contained in:
@@ -33,39 +33,21 @@ namespace AyaNova
|
|||||||
//Get config
|
//Get config
|
||||||
var config = new ConfigurationBuilder().AddJsonFile("config.json", true).AddEnvironmentVariables().AddCommandLine(args).Build();
|
var config = new ConfigurationBuilder().AddJsonFile("config.json", true).AddEnvironmentVariables().AddCommandLine(args).Build();
|
||||||
|
|
||||||
//Ensure we have critical config values set, if not need to bail with clear message
|
//Set config or bail with error for missing items
|
||||||
bool HaveAllCrticalConfigValues = true;
|
try
|
||||||
ServerBootConfig.SetConfiguration(config);
|
|
||||||
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_DB_CONNECTION))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine($"FAIL: AYANOVA_DB_CONNECTION configuration setting missing and required");
|
ServerBootConfig.SetConfiguration(config);
|
||||||
HaveAllCrticalConfigValues = false;
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine($"FAIL: AYANOVA_FOLDER_BACKUP_FILES configuration setting missing and required");
|
Console.WriteLine($"Unable to boot due to configuration error: {ex.Message}");
|
||||||
HaveAllCrticalConfigValues = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_USER_FILES))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"FAIL: AYANOVA_FOLDER_USER_FILES configuration setting missing and required");
|
|
||||||
HaveAllCrticalConfigValues = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"FAIL: AYANOVA_FOLDER_TEMPORARY_SERVER_FILES configuration setting missing and required");
|
|
||||||
HaveAllCrticalConfigValues = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!HaveAllCrticalConfigValues)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Required configuration settings missing; server can not be started");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileUtil.EnsureUserAndUtilityFoldersExistAndAreNotIdentical();
|
FileUtil.EnsureUserAndUtilityFoldersExistAndAreNotIdentical();
|
||||||
@@ -235,21 +217,22 @@ namespace AyaNova
|
|||||||
long UtilityFilesAvailableSpace = 0;
|
long UtilityFilesAvailableSpace = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UtilityFilesAvailableSpace = FileUtil.BackupFilesDriveAvailableSpace();
|
// Console.WriteLine($"##### program:about to call backupfilesdriveavailablespace, config is [{ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES}] ######");
|
||||||
|
UtilityFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)).AvailableFreeSpace;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error(ex, "FileUtil::UtilityFilesDriveAvailableSpace error getting available space");
|
logger.Error(ex, $"BOOT::FileUtil::UtilityFilesDriveAvailableSpace error getting available space from [{Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
long AttachmentFilesAvailableSpace = 0;
|
long AttachmentFilesAvailableSpace = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AttachmentFilesAvailableSpace = FileUtil.AttachmentFilesDriveAvailableSpace();
|
AttachmentFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)).AvailableFreeSpace;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error(ex, "FileUtil::AttachmentFilesDriveAvailableSpace error getting available space");
|
logger.Error(ex, $"BOOT::FileUtil::AttachmentFilesDriveAvailableSpace error getting available space from [{Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.LogError(ex, "FileUtil::UtilityFilesDriveAvailableSpace error getting available space");
|
log.LogError(ex, "Metrics::FileUtil::UtilityFilesDriveAvailableSpace error getting available space");
|
||||||
}
|
}
|
||||||
|
|
||||||
long AttachmentFilesAvailableSpace = 0;
|
long AttachmentFilesAvailableSpace = 0;
|
||||||
@@ -121,7 +121,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.LogError(ex, "FileUtil::AttachmentFilesDriveAvailableSpace error getting available space");
|
log.LogError(ex, "Metrics::FileUtil::AttachmentFilesDriveAvailableSpace error getting available space");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
|
|||||||
@@ -347,9 +347,9 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
internal static long BackupFilesDriveAvailableSpace()
|
internal static long BackupFilesDriveAvailableSpace()
|
||||||
{
|
{
|
||||||
Console.WriteLine("b fileutil:backupfilesdriveavailablespace, backupfilesfolder:", ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES);
|
//Console.WriteLine("b fileutil:backupfilesdriveavailablespace, backupfilesfolder:", ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES);
|
||||||
Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder FULLPATH:", Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES));
|
//Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder FULLPATH:", Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES));
|
||||||
Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder PATHROOT:", Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES));
|
// Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder PATHROOT:", Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES));
|
||||||
return new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)).AvailableFreeSpace;
|
return new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)).AvailableFreeSpace;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ namespace AyaNova.Util
|
|||||||
nTemp = config.GetValue<int?>("AYANOVA_REPORT_RENDERING_MAX_INSTANCES");
|
nTemp = config.GetValue<int?>("AYANOVA_REPORT_RENDERING_MAX_INSTANCES");
|
||||||
AYANOVA_REPORT_RENDERING_MAX_INSTANCES = (null == nTemp) ? 3 : (int)nTemp;
|
AYANOVA_REPORT_RENDERING_MAX_INSTANCES = (null == nTemp) ? 3 : (int)nTemp;
|
||||||
if (AYANOVA_REPORT_RENDERING_MAX_INSTANCES < 1) AYANOVA_REPORT_RENDERING_MAX_INSTANCES = 1; //minimum instances
|
if (AYANOVA_REPORT_RENDERING_MAX_INSTANCES < 1) AYANOVA_REPORT_RENDERING_MAX_INSTANCES = 1; //minimum instances
|
||||||
if (AYANOVA_REPORT_RENDERING_MAX_INSTANCES > 10) AYANOVA_REPORT_RENDERING_MAX_INSTANCES = 10; //Fixed maximum instances
|
if (AYANOVA_REPORT_RENDERING_MAX_INSTANCES > 10) AYANOVA_REPORT_RENDERING_MAX_INSTANCES = 10; //Fixed maximum instances
|
||||||
|
|
||||||
//DB
|
//DB
|
||||||
AYANOVA_DB_CONNECTION = config.GetValue<string>("AYANOVA_DB_CONNECTION");
|
AYANOVA_DB_CONNECTION = config.GetValue<string>("AYANOVA_DB_CONNECTION");
|
||||||
@@ -180,33 +180,68 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
|
|
||||||
//FOLDERS
|
//FOLDERS
|
||||||
|
|
||||||
|
//TODO: Implement system where one single data folder can be specified and AyaNova will use that and subfolders under it automatically
|
||||||
|
//but also it honours if specific overrides were set for alternative locations
|
||||||
|
//change "folder" to "path" and update docs and everywhere it's mentioned
|
||||||
|
//AYANOVA_DATA_PATH <---this is used as "root" for all data paths automatically unless more specific
|
||||||
|
string AyaPath = string.Empty;
|
||||||
|
|
||||||
//Log folder
|
//Log folder
|
||||||
AYANOVA_LOG_PATH = FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_LOG_PATH"));
|
AyaPath = config.GetValue<string>("AYANOVA_LOG_PATH");
|
||||||
|
if (string.IsNullOrWhiteSpace(AyaPath))
|
||||||
|
throw new System.ArgumentNullException("AYANOVA_LOG_PATH configuration setting missing and required");
|
||||||
|
AYANOVA_LOG_PATH = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(AYANOVA_LOG_PATH));
|
||||||
|
/*
|
||||||
|
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_DB_CONNECTION))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"FAIL: AYANOVA_DB_CONNECTION configuration setting missing and required");
|
||||||
|
HaveAllCrticalConfigValues = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"FAIL: AYANOVA_FOLDER_BACKUP_FILES configuration setting missing and required");
|
||||||
|
HaveAllCrticalConfigValues = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(AYANOVA_LOG_PATH))
|
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_USER_FILES))
|
||||||
{
|
{
|
||||||
//DEFAULT LOG PATH
|
Console.WriteLine($"FAIL: AYANOVA_FOLDER_USER_FILES configuration setting missing and required");
|
||||||
var currentDir = Directory.GetCurrentDirectory();
|
HaveAllCrticalConfigValues = false;
|
||||||
AYANOVA_LOG_PATH = Path.Combine(currentDir, "logs");
|
}
|
||||||
}
|
|
||||||
else
|
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES))
|
||||||
{
|
{
|
||||||
AYANOVA_LOG_PATH = Path.Combine(AYANOVA_LOG_PATH, "logs");
|
Console.WriteLine($"FAIL: AYANOVA_FOLDER_TEMPORARY_SERVER_FILES configuration setting missing and required");
|
||||||
}
|
HaveAllCrticalConfigValues = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// if (string.IsNullOrWhiteSpace(AYANOVA_LOG_PATH))
|
||||||
|
// {
|
||||||
|
// //DEFAULT LOG PATH
|
||||||
|
// var currentDir = Directory.GetCurrentDirectory();
|
||||||
|
// AYANOVA_LOG_PATH = Path.Combine(currentDir, "logs");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// AYANOVA_LOG_PATH = Path.Combine(AYANOVA_LOG_PATH, "logs");
|
||||||
|
// }
|
||||||
|
|
||||||
//(note, startup.cs ensures these folders exist via FileUtil because we need IHostingEnvironment)
|
//(note, startup.cs ensures these folders exist via FileUtil because we need IHostingEnvironment)
|
||||||
//UserFiles
|
//UserFiles
|
||||||
AYANOVA_FOLDER_USER_FILES = FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_FOLDER_USER_FILES"));
|
AYANOVA_FOLDER_USER_FILES = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_FOLDER_USER_FILES")));
|
||||||
|
|
||||||
//BackupFiles
|
//BackupFiles
|
||||||
AYANOVA_FOLDER_BACKUP_FILES = FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_FOLDER_BACKUP_FILES"));
|
AYANOVA_FOLDER_BACKUP_FILES = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_FOLDER_BACKUP_FILES")));
|
||||||
|
|
||||||
//TemporaryFiles
|
//TemporaryFiles
|
||||||
AYANOVA_FOLDER_TEMPORARY_SERVER_FILES = FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_FOLDER_TEMPORARY_SERVER_FILES"));
|
AYANOVA_FOLDER_TEMPORARY_SERVER_FILES = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_FOLDER_TEMPORARY_SERVER_FILES")));
|
||||||
|
|
||||||
//pgdump backup utility path
|
//pgdump backup utility path
|
||||||
AYANOVA_BACKUP_PG_DUMP_PATH = FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_BACKUP_PG_DUMP_PATH"));
|
AYANOVA_BACKUP_PG_DUMP_PATH = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue<string>("AYANOVA_BACKUP_PG_DUMP_PATH")));
|
||||||
|
|
||||||
//backdoor back door password superuser reset
|
//backdoor back door password superuser reset
|
||||||
AYANOVA_SET_SUPERUSER_PW = config.GetValue<string>("AYANOVA_SET_SUPERUSER_PW");
|
AYANOVA_SET_SUPERUSER_PW = config.GetValue<string>("AYANOVA_SET_SUPERUSER_PW");
|
||||||
|
|||||||
Reference in New Issue
Block a user