MitchTalmadge / AMP-dockerized

CubeCoders AMP in a Docker Image. Easily create game servers for games like Minecraft, GMod, TF2, Factorio, and StarBound!
https://hub.docker.com/r/mitchtalmadge/amp-dockerized
Other
91 stars 22 forks source link

Generic Module #15

Closed MitchTalmadge closed 4 years ago

MitchTalmadge commented 4 years ago

AMP 1.9.5.0 just got announced with support for a "generic" module that lets you run anything you want. This will need to be tested

MitchTalmadge commented 4 years ago

Copying the announcement from Discord:

Hey everyone - AMP 1.9.5.0 is here! This is the one you've been waiting for - with a properly fleshed out 'Generic' module! Now it's easy as pie to run arbitrary applications within AMP, and keep them up-to-date too! It can pull servers from SteamCMD or from a URL. Share your configurations with other users or send push requests to our repo! Release notes here: https://support.cubecoders.com/thread/amp-1-9-5-0-lapetus-release-notes/ and documentation on the generic module here: https://github.com/CubeCoders/AMP/wiki/Configuring-the-'Generic'-AMP-module - Also, some swanky UI changes! smile

TABLE272 commented 4 years ago

Went ahead and gave the Terraria generic module template provided by cubecoders a go to see how it went. First attempt failed downloaded the game successfully, but during world gen, immediately after completion of the "Resetting game objects" task, the server would loop with the following error.

Unhandled Exception:
System.UnauthorizedAccessException: Access to the path "/home/amp/.local" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00070] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.IO.DirectoryInfo.Create () [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0003f] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.IO.DirectoryInfo.Create () [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0003f] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <1170fb08300b4d0db71c1d1db8555768>:0
at Terraria.Utilities.FileUtilities.Write (System.String path, System.Byte[] data, System.Int32 length, System.Boolean cloud) [0x0002e] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.Utilities.FileUtilities.WriteAllBytes (System.String path, System.Byte[] data, System.Boolean cloud) [0x00000] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.IO.FavoritesFile.Save () [0x00019] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.IO.FavoritesFile.SaveFavorite (Terraria.IO.FileData fileData) [0x0004c] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.IO.FileData.SetFavorite (System.Boolean favorite, System.Boolean saveChanges) [0x00019] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.IO.WorldFile.CreateMetadata (System.String name, System.Boolean cloudSave, System.Boolean isExpertMode) [0x00033] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.IO.WorldFile.loadWorld (System.Boolean loadFromCloud) [0x000b8] in <44adbf0850c348d0b0673c0943134ba4>:0
at Terraria.WorldGen.serverLoadWorldCallBack (System.Object threadContext) [0x00022] in <44adbf0850c348d0b0673c0943134ba4>:0
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000e] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x0002a] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
15:00:34

I resolved this by a docker exec into the container and creating the directory manually. After this point the server booted up fine. Since amp was able to install the server itself fine, this appears to be something Terraria itself does, as opposed to a compatibility issue with generic modules themselves.

Upon further inspection, this ".local" leads to ~/.local/share/Terraria which contains favorites.json and the Worlds directory, which appears to be where the world is stored.

I'm going to look around terrarias own config files and see if this directory can be redefined, else if I'm right it would require shifting our /home/amp/.ampdata mount to just /home/amp, or alternatively mounting /home/amp/.local individually.

This might all become irrelevant when the official terraria module comes around anyway.

Edit: Fixed the above, does appear to be an issue just with terraria. The game has a "-savedirectory" runtime argument. I've added this argument into the cubecoders template so as to automatically create a ~/saves directory in the game's own folder.

Incase anyone else would benefit from it, heres the change.

App.CommandLineArgs=-world {{WorldName}} -autocreate {{WorldSize}} -savedirectory {{SaveDir}} -players {{$MaxUsers}} -port {{$ApplicatonPort1}} 
App.CommandLineVars={"WorldSize": 1, "WorldName" : "test", "SaveDir" : "saves"}
MitchTalmadge commented 4 years ago

Very nice, thanks @skylaar727!! It sounds like this generic module is gonna require hacks for everything that will ever run on it, since everything is different. We could perhaps start a wiki to log some of our findings for generic modules, but I'm also ok with not doing that. I wouldn't be able to maintain it very well.

I was mostly interested to see if it was possible to get something working at all without too much trouble, and it looks like the answer is yes, so that's a win! I'm gonna close this, and if people wanna open issues for help with their individual adventures I'm happy to help where I can.