Initialize log should be first so we can log any errors.
Removed duplicate code in Initialize
This commit is contained in:
parent
7f5324795c
commit
50084c13de
1 changed files with 12 additions and 23 deletions
|
|
@ -100,24 +100,6 @@ namespace TShockAPI
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(SavePath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(SavePath);
|
|
||||||
}
|
|
||||||
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
|
|
||||||
{
|
|
||||||
Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
|
|
||||||
File.Delete(Path.Combine(SavePath, "tshock.pid"));
|
|
||||||
}
|
|
||||||
|
|
||||||
TShockProcess = Process.GetCurrentProcess();
|
|
||||||
int pid = TShockProcess.Id;
|
|
||||||
TextWriter tw = new StreamWriter(Path.Combine(SavePath, "tshock.pid"));
|
|
||||||
tw.Write(pid);
|
|
||||||
tw.Close();
|
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
|
Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
|
||||||
#else
|
#else
|
||||||
|
|
@ -125,17 +107,23 @@ namespace TShockAPI
|
||||||
#endif
|
#endif
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
|
if (!Directory.Exists(SavePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SavePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
|
||||||
|
{
|
||||||
|
Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
|
||||||
|
File.Delete(Path.Combine(SavePath, "tshock.pid"));
|
||||||
|
}
|
||||||
|
File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString());
|
||||||
|
|
||||||
ConfigFile.ConfigRead += OnConfigRead;
|
ConfigFile.ConfigRead += OnConfigRead;
|
||||||
FileTools.SetupConfig();
|
FileTools.SetupConfig();
|
||||||
|
|
||||||
HandleCommandLine(Environment.GetCommandLineArgs());
|
HandleCommandLine(Environment.GetCommandLineArgs());
|
||||||
|
|
||||||
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
|
|
||||||
|
|
||||||
FileTools.SetupConfig();
|
|
||||||
|
|
||||||
if (Config.StorageType.ToLower() == "sqlite")
|
if (Config.StorageType.ToLower() == "sqlite")
|
||||||
{
|
{
|
||||||
string sql = Path.Combine(SavePath, "tshock.sqlite");
|
string sql = Path.Combine(SavePath, "tshock.sqlite");
|
||||||
|
|
@ -168,6 +156,7 @@ namespace TShockAPI
|
||||||
throw new Exception("Invalid storage type");
|
throw new Exception("Invalid storage type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
|
||||||
Bans = new BanManager(DB);
|
Bans = new BanManager(DB);
|
||||||
Warps = new WarpManager(DB);
|
Warps = new WarpManager(DB);
|
||||||
Users = new UserManager(DB);
|
Users = new UserManager(DB);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue