private static void RegisterCoreDependencies(ContainerBuilder containerBuilder) { containerBuilder.Register(c => PropertiesWriter.Deserialize <ServerConfig>()).SingleInstance(); containerBuilder.RegisterType <Server>().SingleInstance(); containerBuilder.RegisterType <PlayerManager>().SingleInstance(); containerBuilder.RegisterType <DefaultServerPacketProcessor>().InstancePerLifetimeScope(); containerBuilder.RegisterType <PacketHandler>().InstancePerLifetimeScope(); containerBuilder.RegisterType <EscapePodManager>().InstancePerLifetimeScope(); containerBuilder.RegisterType <EntitySimulation>().SingleInstance(); containerBuilder.RegisterType <ConsoleCommandProcessor>().SingleInstance(); containerBuilder.RegisterType <LiteNetLibServer>() .As <Communication.NetworkingLayer.NitroxServer>() .SingleInstance(); }
protected override void Execute(CallArgs args) { if (!configOpenLock.Wait(0)) { Log.Warn("Waiting on previous config command to close the configuration file."); return; } ServerConfig currentActiveConfig = NitroxServiceLocator.LocateService <ServerConfig>(); string configFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? "", currentActiveConfig.FileName); if (!File.Exists(configFile)) { Log.Error($"Could not find config file at: {configFile}"); return; } Task.Run(async() => { try { await StartWithDefaultProgram(configFile); } finally { configOpenLock.Release(); } PropertiesWriter.Deserialize <ServerConfig>(); // Notifies user if deserialization failed. Log.Info("If you made changes, restart the server for them to take effect."); }) .ContinueWith(t => { #if DEBUG if (t.Exception != null) { throw t.Exception; } #endif }); }