This commit is contained in:
@@ -33,39 +33,21 @@ namespace AyaNova
|
||||
//Get config
|
||||
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
|
||||
bool HaveAllCrticalConfigValues = true;
|
||||
ServerBootConfig.SetConfiguration(config);
|
||||
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_DB_CONNECTION))
|
||||
//Set config or bail with error for missing items
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"FAIL: AYANOVA_DB_CONNECTION configuration setting missing and required");
|
||||
HaveAllCrticalConfigValues = false;
|
||||
ServerBootConfig.SetConfiguration(config);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES))
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"FAIL: AYANOVA_FOLDER_BACKUP_FILES configuration setting missing and required");
|
||||
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");
|
||||
Console.WriteLine($"Unable to boot due to configuration error: {ex.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
FileUtil.EnsureUserAndUtilityFoldersExistAndAreNotIdentical();
|
||||
@@ -235,21 +217,22 @@ namespace AyaNova
|
||||
long UtilityFilesAvailableSpace = 0;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
try
|
||||
{
|
||||
AttachmentFilesAvailableSpace = FileUtil.AttachmentFilesDriveAvailableSpace();
|
||||
AttachmentFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)).AvailableFreeSpace;
|
||||
}
|
||||
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)
|
||||
{
|
||||
log.LogError(ex, "FileUtil::UtilityFilesDriveAvailableSpace error getting available space");
|
||||
log.LogError(ex, "Metrics::FileUtil::UtilityFilesDriveAvailableSpace error getting available space");
|
||||
}
|
||||
|
||||
long AttachmentFilesAvailableSpace = 0;
|
||||
@@ -121,7 +121,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -347,9 +347,9 @@ namespace AyaNova.Util
|
||||
|
||||
internal static long BackupFilesDriveAvailableSpace()
|
||||
{
|
||||
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 PATHROOT:", Path.GetPathRoot(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 PATHROOT:", Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES));
|
||||
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");
|
||||
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 > 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
|
||||
AYANOVA_DB_CONNECTION = config.GetValue<string>("AYANOVA_DB_CONNECTION");
|
||||
@@ -180,33 +180,68 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
//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
|
||||
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))
|
||||
{
|
||||
//DEFAULT LOG PATH
|
||||
var currentDir = Directory.GetCurrentDirectory();
|
||||
AYANOVA_LOG_PATH = Path.Combine(currentDir, "logs");
|
||||
}
|
||||
else
|
||||
{
|
||||
AYANOVA_LOG_PATH = Path.Combine(AYANOVA_LOG_PATH, "logs");
|
||||
}
|
||||
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 (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)
|
||||
//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
|
||||
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
|
||||
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
|
||||
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
|
||||
AYANOVA_SET_SUPERUSER_PW = config.GetValue<string>("AYANOVA_SET_SUPERUSER_PW");
|
||||
|
||||
Reference in New Issue
Block a user