Update background task time scheduling to use server local time. Ensure that the TZ variable is passed to the container with the location of the server. (#268)
* Remove LastRun values during upgrade * Add timezone variable to docker-compose files * Release note update to include PR's labeled "note"
This commit is contained in:
4
.github/release.yml
vendored
4
.github/release.yml
vendored
@@ -5,8 +5,12 @@ changelog:
|
|||||||
- '*'
|
- '*'
|
||||||
exclude:
|
exclude:
|
||||||
labels:
|
labels:
|
||||||
|
- note
|
||||||
- bug
|
- bug
|
||||||
- dependencies
|
- dependencies
|
||||||
|
- title: Notes
|
||||||
|
labels:
|
||||||
|
- note
|
||||||
- title: Bug Fixes
|
- title: Bug Fixes
|
||||||
labels:
|
labels:
|
||||||
- bug
|
- bug
|
||||||
|
@@ -14,6 +14,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- gs:/root/.gaseous-server
|
- gs:/root/.gaseous-server
|
||||||
environment:
|
environment:
|
||||||
|
- TZ=Australia/Sydney
|
||||||
- dbhost=gsdb
|
- dbhost=gsdb
|
||||||
- dbuser=root
|
- dbuser=root
|
||||||
- dbpass=gaseous
|
- dbpass=gaseous
|
||||||
|
@@ -13,6 +13,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- gs:/root/.gaseous-server
|
- gs:/root/.gaseous-server
|
||||||
environment:
|
environment:
|
||||||
|
- TZ=Australia/Sydney
|
||||||
- dbhost=gsdb
|
- dbhost=gsdb
|
||||||
- dbuser=root
|
- dbuser=root
|
||||||
- dbpass=gaseous
|
- dbpass=gaseous
|
||||||
|
@@ -14,6 +14,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- gs:/root/.gaseous-server
|
- gs:/root/.gaseous-server
|
||||||
environment:
|
environment:
|
||||||
|
- TZ=Australia/Sydney
|
||||||
- dbhost=gsdb
|
- dbhost=gsdb
|
||||||
- dbuser=root
|
- dbuser=root
|
||||||
- dbpass=gaseous
|
- dbpass=gaseous
|
||||||
|
@@ -13,6 +13,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- gs:/root/.gaseous-server
|
- gs:/root/.gaseous-server
|
||||||
environment:
|
environment:
|
||||||
|
- TZ=Australia/Sydney
|
||||||
- dbhost=gsdb
|
- dbhost=gsdb
|
||||||
- dbuser=root
|
- dbuser=root
|
||||||
- dbpass=gaseous
|
- dbpass=gaseous
|
||||||
|
@@ -172,76 +172,123 @@ namespace gaseous_server.Classes
|
|||||||
DataTable dbResponse = db.ExecuteCMD(sql);
|
DataTable dbResponse = db.ExecuteCMD(sql);
|
||||||
foreach (DataRow dataRow in dbResponse.Rows)
|
foreach (DataRow dataRow in dbResponse.Rows)
|
||||||
{
|
{
|
||||||
if (AppSettings.ContainsKey((string)dataRow["Setting"]))
|
string SettingName = (string)dataRow["Setting"];
|
||||||
|
|
||||||
|
if (AppSettings.ContainsKey(SettingName))
|
||||||
{
|
{
|
||||||
if ((int)dataRow["ValueType"] == 0)
|
AppSettings.Remove(SettingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.Log(Logging.LogType.Information, "Load Settings", "Loading setting " + SettingName + " from database");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch ((int)dataRow["ValueType"])
|
||||||
{
|
{
|
||||||
AppSettings[(string)dataRow["Setting"]] = (string)dataRow["Value"];
|
case 0:
|
||||||
}
|
default:
|
||||||
else
|
// value is a string
|
||||||
{
|
AppSettings.Add(SettingName, dataRow["Value"]);
|
||||||
AppSettings[(string)dataRow["Setting"]] = (DateTime)dataRow["ValueDate"];
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// value is a datetime
|
||||||
|
AppSettings.Add(SettingName, dataRow["ValueDate"]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (InvalidCastException castEx)
|
||||||
{
|
{
|
||||||
if ((int)dataRow["ValueType"] == 0)
|
Logging.Log(Logging.LogType.Warning, "Settings", "Exception when reading server setting " + SettingName + ". Resetting to default.", castEx);
|
||||||
|
|
||||||
|
// delete broken setting and return the default
|
||||||
|
// this error is probably generated during an upgrade
|
||||||
|
sql = "DELETE FROM Settings WHERE Setting = @SettingName";
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
AppSettings.Add((string)dataRow["Setting"], (string)dataRow["Value"]);
|
{ "SettingName", SettingName }
|
||||||
}
|
};
|
||||||
else
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
AppSettings.Add((string)dataRow["Setting"], (DateTime)dataRow["ValueDate"]);
|
{
|
||||||
}
|
Logging.Log(Logging.LogType.Critical, "Settings", "Exception when reading server setting " + SettingName + ".", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T ReadSetting<T>(string SettingName, T DefaultValue)
|
public static T ReadSetting<T>(string SettingName, T DefaultValue)
|
||||||
{
|
{
|
||||||
if (AppSettings.ContainsKey(SettingName))
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return (T)AppSettings[SettingName];
|
if (AppSettings.ContainsKey(SettingName))
|
||||||
|
{
|
||||||
|
return (T)AppSettings[SettingName];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
string sql = "SELECT Value, ValueDate FROM Settings WHERE Setting = @SettingName";
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "SettingName", SettingName }
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Logging.Log(Logging.LogType.Debug, "Database", "Reading setting '" + SettingName + "'");
|
||||||
|
DataTable dbResponse = db.ExecuteCMD(sql, dbDict);
|
||||||
|
Type type = typeof(T);
|
||||||
|
if (dbResponse.Rows.Count == 0)
|
||||||
|
{
|
||||||
|
// no value with that name stored - respond with the default value
|
||||||
|
SetSetting<T>(SettingName, DefaultValue);
|
||||||
|
return DefaultValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (type.ToString() == "System.DateTime")
|
||||||
|
{
|
||||||
|
AppSettings.Add(SettingName, dbResponse.Rows[0]["ValueDate"]);
|
||||||
|
return (T)dbResponse.Rows[0]["ValueDate"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AppSettings.Add(SettingName, dbResponse.Rows[0]["Value"]);
|
||||||
|
return (T)dbResponse.Rows[0]["Value"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.Log(Logging.LogType.Critical, "Database", "Failed reading setting " + SettingName, ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (InvalidCastException castEx)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Logging.Log(Logging.LogType.Warning, "Settings", "Exception when reading server setting " + SettingName + ". Resetting to default.", castEx);
|
||||||
string sql = "SELECT Value, ValueDate FROM Settings WHERE Setting = @SettingName";
|
|
||||||
|
// delete broken setting and return the default
|
||||||
|
// this error is probably generated during an upgrade
|
||||||
|
if (AppSettings.ContainsKey(SettingName))
|
||||||
|
{
|
||||||
|
AppSettings.Remove(SettingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
string sql = "DELETE FROM Settings WHERE Setting = @SettingName";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
Dictionary<string, object> dbDict = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ "SettingName", SettingName }
|
{ "SettingName", SettingName }
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
return DefaultValue;
|
||||||
{
|
}
|
||||||
Logging.Log(Logging.LogType.Debug, "Database", "Reading setting '" + SettingName + "'");
|
catch (Exception ex)
|
||||||
DataTable dbResponse = db.ExecuteCMD(sql, dbDict);
|
{
|
||||||
Type type = typeof(T);
|
Logging.Log(Logging.LogType.Critical, "Settings", "Exception when reading server setting " + SettingName + ".", ex);
|
||||||
if (dbResponse.Rows.Count == 0)
|
throw;
|
||||||
{
|
|
||||||
// no value with that name stored - respond with the default value
|
|
||||||
SetSetting<T>(SettingName, DefaultValue);
|
|
||||||
return DefaultValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (type.ToString() == "System.DateTime")
|
|
||||||
{
|
|
||||||
AppSettings.Add(SettingName, dbResponse.Rows[0]["ValueDate"]);
|
|
||||||
return (T)dbResponse.Rows[0]["ValueDate"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AppSettings.Add(SettingName, dbResponse.Rows[0]["Value"]);
|
|
||||||
return (T)dbResponse.Rows[0]["Value"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logging.Log(Logging.LogType.Critical, "Database", "Failed reading setting " + SettingName, ex);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ namespace gaseous_server.Classes
|
|||||||
public static void PostUpgradeScript(int TargetSchemaVersion, Database.databaseType? DatabaseType)
|
public static void PostUpgradeScript(int TargetSchemaVersion, Database.databaseType? DatabaseType)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
string sql = "";
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||||
|
|
||||||
switch(DatabaseType)
|
switch(DatabaseType)
|
||||||
@@ -32,7 +33,7 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
// copy root path to new libraries format
|
// copy root path to new libraries format
|
||||||
string oldRoot = Path.Combine(Config.LibraryConfiguration.LibraryRootDirectory, "Library");
|
string oldRoot = Path.Combine(Config.LibraryConfiguration.LibraryRootDirectory, "Library");
|
||||||
string sql = "INSERT INTO GameLibraries (Name, Path, DefaultLibrary, DefaultPlatform) VALUES (@name, @path, @defaultlibrary, @defaultplatform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
sql = "INSERT INTO GameLibraries (Name, Path, DefaultLibrary, DefaultPlatform) VALUES (@name, @path, @defaultlibrary, @defaultplatform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
|
||||||
dbDict.Add("name", "Default");
|
dbDict.Add("name", "Default");
|
||||||
dbDict.Add("path", oldRoot);
|
dbDict.Add("path", oldRoot);
|
||||||
dbDict.Add("defaultlibrary", 1);
|
dbDict.Add("defaultlibrary", 1);
|
||||||
@@ -46,6 +47,11 @@ namespace gaseous_server.Classes
|
|||||||
db.ExecuteCMD(sql, dbDict);
|
db.ExecuteCMD(sql, dbDict);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1016:
|
||||||
|
// delete old format LastRun_* settings from settings table
|
||||||
|
sql = "DELETE FROM Settings WHERE Setting LIKE 'LastRun_%';";
|
||||||
|
db.ExecuteNonQuery(sql);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user