AMP icon indicating copy to clipboard operation
AMP copied to clipboard

Generic Instances Do Not Wake Up

Open IceOfWraith opened this issue 3 years ago • 6 comments

Bug Report

System Information

  • Operating System: Windows 11 Pro
  • AMP version and build date: v20220216.1, built 16/02/2022 03:00
  • Which AMP release stream you're using: Nightly

I confirm:

  • [x] that I have searched for an existing bug report for this issue.
  • [x] that I am using the latest available version of AMP.
  • [x] that my operating system is up-to-date.

Symptoms

  • What are you trying to do? Wake up a Generic Module server using the Wake Up button.
  • What are you expecting to happen? When a server is asleep, it should wake up with the button in AMP.
  • What is actually happening?

I'm getting the following in the GUI:

image

And the following in the log: [20:36:38] [Generic:admin Info]   : Sleep on start is enabled, sleeping now... [20:37:08] [System:admin Warning] : Application failed to stop after 30 seconds. Terminating... [20:37:12] [API:admin Activity]   : Starting the application. [20:37:12] [APIService:admin Warning] : Returned exception from API call Core/Start [20:37:12] [Core:admin Error]     : NullReferenceException [20:37:12] [Core:admin Error]     : [0] (NullReferenceException) : Object reference not set to an instance of an object. [20:37:12] [Core:admin Error]     : at GenericModule.UniversalSleep.Stop() at GenericModule.GenericApp.SleepServer_Wakeup(Object sender, EventArgs e) at GenericModule.GenericApp.Start() at GSMyAdmin.WebServer.WebMethods.Start() at GSMyAdmin.WebServer.WebAttributes.InvokeMethod(String MethodName, JObject Data, IHttpRequest request, IWebSession Session, WebMethodsBase MethodsClass, String RawRequest) at GSMyAdmin.WebServer.APIService.InvokeAPI(IHttpRequest request, IWebSession Session, JObject Data, String RequestModule, String RequestMethod, String RawRequest)

Reproduction

Create a Valheim instance with sleep on start enabled. After it goes to bed, try to wake it up. You can't because it acts like a teen on a school day. It just won't budge.

I tested with Valheim, Risk of Rain 2, and Stationeers. All had the same symptoms.

IceOfWraith avatar Feb 17 '22 02:02 IceOfWraith

After further testing, I think the root cause is that when AMP is running as a service in Windows it can't properly stop the game server using OS_CLOSE or WM_CLOSE. This is just a hunch, but I think that without a proper shutdown it gives an error on starting back up?

IceOfWraith avatar Feb 20 '22 15:02 IceOfWraith

I see also that OS_CLOSE does not work on Windows. For example with Eco, it works fine on Linux, but not with Windows.

The official way to close the Eco server on Linux is SIGINT or Ctrl-C, so it makes sense that OS_CLOSE works on Linux.

However, Ctrl-C also does not work on Windows.

Greelan avatar Feb 24 '22 08:02 Greelan

OK, with the change introduced recently for OS_CLOSE on Windows, am seeing some progress.

Using Nightly (v20220304.1) for Eco, for example, hitting Stop (which is configured to send OS_CLOSE), the server does save and start a shutdown procedure. BUT, the instance itself is also stopped:

[04:16:30] [Core Info]            : Stop requested: Double CTRL+C recieved
[04:16:30] [Core Notice]          : AMP shutdown requested.
[04:16:30] [Core Notice]          : Stopping Application...
[04:16:30] [Core Info]            : Stop requested: Double CTRL+C recieved
[04:16:30] Saving... 
[04:16:31] Saving... Finished in 850.0ms
[04:16:31] Shutting down IntegrationTestsPlugin... 
[04:16:31] Shutting down IntegrationTestsPlugin... Finished in 0.4ms
[04:16:31] Shutting down WorldLayerManager... 
[04:16:31] Shutting down WorldLayerManager... Finished in 11.4ms
[04:16:31] Shutting down VoiceManager... 
[04:16:31] Shutting down VoiceManager... Finished in 0.2ms
[04:16:31] Shutting down NetworkManager... 
[04:16:31] Shutting down NetworkManager... Finished in 9.8ms
[04:16:31] Shutting down SettlementsPlugin... 
[04:16:31] Shutting down SettlementsPlugin... Finished in 0.2ms
[04:16:31] Shutting down WorldPlugin... 
[04:16:31] Shutting down WorldPlugin... Finished in 0.3ms
[04:16:31] Shutting down RconPlugin... 
[04:16:31] Shutting down RconPlugin... Finished in 5.9ms
[04:16:31] Shutting down GameActionAccumulator... 
[04:16:31] Shutting down GameActionAccumulator... Finished in 9.4ms
[04:16:31] Shutting down SleepPlugin... 
[04:16:31] Shutting down SleepPlugin... Finished in 1.0ms
[04:16:31] Shutting down RoomPlugin... 
[04:16:31] Shutting down RoomPlugin... Finished in 1.2ms
[04:16:31] Shutting down WorldObjectManager... 
[04:16:31] Shutting down WorldObjectManager... Finished in 0.4ms
[04:16:31] Shutting down EconomyTracker... 
[04:16:31] Shutting down EconomyTracker... Finished in 0.4ms
[04:16:31] Shutting down RouteProbingPlugin... 
[04:16:31] Shutting down RouteProbingPlugin... Finished in 0.3ms
[04:16:31] Shutting down EcoSim... 
[04:16:31] Shutting down EcoSim... Finished in 0.4ms
[04:16:31] Shutting down MinimapManager... 
[04:16:31] Shutting down MinimapManager... Finished in 0.0ms
[04:16:31] Shutting down PropertyManager... 
[04:16:31] Shutting down PropertyManager... Finished in 0.0ms
[04:16:31] Shutting down GarbagePlugin... 
[04:16:31] Shutting down GarbagePlugin... Finished in 1.9ms
[04:16:31] Shutting down EconomyPlugin... 
[04:16:31] Shutting down EconomyPlugin... Finished in 3.5ms
[04:16:31] Shutting down DisasterPlugin... 
[04:16:31] Shutting down DisasterPlugin... Finished in 0.1ms
[04:16:31] Shutting down ControllerManager... 
[04:16:31] Shutting down ControllerManager... Finished in 0.1ms
[04:16:31] Shutting down UserManager... 
[04:16:31] Shutting down UserManager... Finished in 2.7ms
[04:16:31] Shutting down ReputationPlugin... 
[04:16:31] Shutting down ReputationPlugin... Finished in 2.7ms
[04:16:31] Shutting down TimePlugin... 
[04:16:31] Shutting down TimePlugin... Finished in 0.5ms
[04:16:31] Shutting down BackupPlugin... 
[04:16:31] Shutting down BackupPlugin... Finished in 35.0ms
[04:16:31] Shutting down PerformancePlugin... 
[04:16:31] Shutting down PerformancePlugin... Finished in 0.2ms
[04:16:31] Shutting down CivicsPlugin... 
[04:16:31] Shutting down CivicsPlugin... Finished in 1.6ms
[04:16:31] Shutting down Stats... 
[04:16:31] Rebuilding database... 
[04:16:31] Rebuilding database... Finished in 84.8ms
[04:16:31] Shutting down Stats... Finished in 106.7ms
[04:16:31] Shutting down StorageManager... 
[04:16:31] Shutting down StorageManager... Finished in 60.2ms
[04:16:31] Shutdown finished
[04:16:35] [Core Notice]          : Stopping Web Server...
[04:16:35] [Core Info]            : Web server shutdown.
[04:16:35] [Core Notice]          : Goodbye!
Rest in peace - Stephen Hawking 1942-2018
[04:16:35] [WebServer Warning]    : RouterTimer@10Hz stopped

Greelan avatar Mar 04 '22 04:03 Greelan

To provide an update on this, I've been unable to get any instances aside from Valheim to sleep still. The instances can stop properly now, but sleep is completely non-functional. Sleep on Start and/or pressing the Sleep button does nothing other than log that the application is going to sleep [16:14:09] [System:admin Activity] : Sleeping the application.. The application continues running with no change in status. Here are the settings I have assigned for Conan as verification it isn't a config issue: App.SupportsUniversalSleep=True App.UniversalSleepApplicationUDPPort=1 App.UniversalSleepSteamQueryPort=3 App.WakeupMode=Any Limits.SleepMode=True Limits.SleepOnStart=False Limits.SleepDelayMinutes=5 Limits.DozeDelay=2 Limits.AutoRetryCount=5 Limits.SleepStartThresholdSeconds=600

IceOfWraith avatar May 07 '22 21:05 IceOfWraith

Note that the application does take somewhere between 30-60 seconds to start, but that's within the threshold I've set.

IceOfWraith avatar May 07 '22 21:05 IceOfWraith

It still works on Unturned. Who would have thought that nightmare would be a poster child for something :)

Greelan avatar May 07 '22 22:05 Greelan

I've tested this against a new bank of unit tests and against a couple of games, but I could use a hand just checking this on any that people have been having specific issue with. I'm also going to remove the LTS tag from this as I don't see a massive reason to delay the release even if this issue is still present.

PhonicUK avatar Dec 18 '22 16:12 PhonicUK