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()
|
||||
{
|
||||
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
|
||||
Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
|
||||
#else
|
||||
|
|
@ -125,17 +107,23 @@ namespace TShockAPI
|
|||
#endif
|
||||
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;
|
||||
FileTools.SetupConfig();
|
||||
|
||||
HandleCommandLine(Environment.GetCommandLineArgs());
|
||||
|
||||
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
|
||||
|
||||
FileTools.SetupConfig();
|
||||
|
||||
if (Config.StorageType.ToLower() == "sqlite")
|
||||
{
|
||||
string sql = Path.Combine(SavePath, "tshock.sqlite");
|
||||
|
|
@ -168,6 +156,7 @@ namespace TShockAPI
|
|||
throw new Exception("Invalid storage type");
|
||||
}
|
||||
|
||||
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
|
||||
Bans = new BanManager(DB);
|
||||
Warps = new WarpManager(DB);
|
||||
Users = new UserManager(DB);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue