palworld-server-docker icon indicating copy to clipboard operation
palworld-server-docker copied to clipboard

set palworldsettings via envsubst and templating

Open MSpreckels opened this issue 1 year ago • 28 comments

Hi there!

I've got another idea for setting the PalWorldSettings.ini!

In my example I use a template file that has environment variables set for each parameter. Using envsubst I patch those env vars in while also setting a default value for each.

I have tested if the variables are set in file but not ingame, yet.

MSpreckels avatar Jan 29 '24 16:01 MSpreckels

This is way cleaner, way easier to maintain long-term, and moves server settings directly to wherever the container image is declared. That's big.

Some things to test,

  • Server name / description, something with spaces, SERVER_NAME="A server with spaces in it's name"

Twinki14 avatar Jan 29 '24 21:01 Twinki14

I wanted to wait for some feedback before i continue working on it and building it further. There is still alot to test about e.g. i already saw that string arent properly parsed. Will continue work on this tomorrow

MSpreckels avatar Jan 29 '24 22:01 MSpreckels

@MSpreckels Keep doing that you are doing, this sounds like an awesome solution

thijsvanloef avatar Jan 30 '24 07:01 thijsvanloef

i've tested it, works for me.

Some considerations:

  • Should i keep the debug output?
  • What kind of naming do i use for envronment variables?
    • SERVER_PLAYER_MAX_NUM vs PLAYERS

Tagging you @Twinki14 @thijsvanloef because you were commenting

MSpreckels avatar Jan 30 '24 16:01 MSpreckels

@MSpreckels keep the naming as close to the PalWorldSettings.ini, except for the ones that introduce breaking changes.

Tonight I'll test your PR as well, thanks for all your work

thijsvanloef avatar Jan 30 '24 17:01 thijsvanloef

Also some more things to test:

  • SERVER_NAME=hello world
  • "SERVER_NAME=hello world"
  • SERVER_NAME=https://github.com
  • "SERVER_NAME=https://github.com"
  • SERVER_NAME=special -&/#@ characters
  • "SERVER_NAME=special -&/#@ characters" Too see if everything gets handled correctly

thijsvanloef avatar Jan 30 '24 18:01 thijsvanloef

@MSpreckels keep the naming as close to the PalWorldSettings.ini, except for the ones that introduce breaking changes.

Tonight I'll test your PR as well, thanks for all your work

will check that tomorrow

Also some more things to test:

  • SERVER_NAME=hello world
  • "SERVER_NAME=hello world"
  • SERVER_NAME=https://github.com
  • "SERVER_NAME=https://github.com"
  • SERVER_NAME=special -&/#@ characters
  • "SERVER_NAME=special -&/#@ characters" Too see if everything gets handled correctly

These are the results when i put the values in the config map:

  1. https://i.imgur.com/ie7T2L0.png
  2. https://i.imgur.com/0xZVgkb.png
  3. https://i.imgur.com/m2xlytD.png

SERVER_NAME = value and SERVER_NAME = "value" give the same results

SERVER_NAME = "\"value\"" breaks it tho

if you could test it using the docker command would be nice

MSpreckels avatar Jan 30 '24 18:01 MSpreckels

@MSpreckels As for the debug question (sorry missed it completely) I would like a DEBUG env var to switch them on. But disable them by default

thijsvanloef avatar Jan 30 '24 20:01 thijsvanloef

@MSpreckels Initial testing does not seem very succesfull, all PalWorldSettings.ini are set correctly, however it does not seem to work ingame: PalWorldSettings.ini

[/Script/Pal.PalGameWorldSettings]
OptionSettings=(
Difficulty=None,
DayTimeSpeedRate=1.000000,
NightTimeSpeedRate=1.000000,
ExpRate=1.000000,
PalCaptureRate=1.000000,
PalSpawnNumRate=1.000000,
PalDamageRateAttack=1.000000,
PalDamageRateDefense=1.000000,
PlayerDamageRateAttack=1.000000,
PlayerDamageRateDefense=1.000000,
PlayerStomachDecreaceRate=1.000000,
PlayerStaminaDecreaceRate=1.000000,
PlayerAutoHPRegeneRate=1.000000,
PlayerAutoHpRegeneRateInSleep=1.000000,
PalStomachDecreaceRate=1.000000,
PalStaminaDecreaceRate=1.000000,
PalAutoHPRegeneRate=1.000000,
PalAutoHpRegeneRateInSleep=1.000000,
BuildObjectDamageRate=1.000000,
BuildObjectDeteriorationDamageRate=1.000000,
CollectionDropRate=1.000000,
CollectionObjectHpRate=1.000000,
CollectionObjectRespawnSpeedRate=1.000000,
EnemyDropItemRate=1.000000,
DeathPenalty=All,
bEnablePlayerToPlayerDamage=False,
bEnableFriendlyFire=False,
bEnableInvaderEnemy=True,
bActiveUNKO=False,
bEnableAimAssistPad=True,
bEnableAimAssistKeyboard=False,
DropItemMaxNum=3000,
DropItemMaxNum_UNKO=100,
BaseCampMaxNum=128,
BaseCampWorkerMaxNum=15,
DropItemAliveMaxHours=1.000000,
bAutoResetGuildNoOnlinePlayers=False,
AutoResetGuildTimeNoOnlinePlayers=72.000000,
GuildPlayerMaxNum=20,
PalEggDefaultHatchingTime=72.000000,
WorkSpeedRate=1.000000,
bIsMultiplay=False,
bIsPvP=False,
bCanPickupOtherGuildDeathPenaltyDrop=False,
bEnableNonLoginPenalty=True,
bEnableFastTravel=True,
bIsStartLocationSelectByMap=True,
bExistPlayerAfterLogout=False,
bEnableDefenseOtherGuildPlayer=False,
CoopPlayerMaxNum=4,
ServerPlayerMaxNum=16,
ServerName="World of Pals",
ServerDescription="Dit is een Test",
AdminPassword="adminPasswordHere",
ServerPassword="Test 123 ofpals",
PublicPort=8211,
PublicIP="",
RCONEnabled=true,
RCONPort=25575,
Region="",
bUseAuth=True,
BanListURL="https://api.palworldgame.com/api/banlist.txt"
)

Logs:

palworld-server  | *****GENERATING CONFIGS*****
palworld-server  | ====Debug====
palworld-server  | DIFFICULTY = None
palworld-server  | DAY_TIME_SPEED_RATE = 1.000000
palworld-server  | NIGHT_TIME_SPEED_RATE = 1.000000
palworld-server  | EXP_RATE = 1.000000
palworld-server  | PAL_CAPTURE_RATE = 1.000000
palworld-server  | PAL_SPAWN_NUM_RATE = 1.000000
palworld-server  | PAL_DAMAGE_RATE_ATTACK = 1.000000
palworld-server  | PAL_DAMAGE_RATE_DEFENSE = 1.000000
palworld-server  | PLAYER_DAMAGE_RATE_ATTACK = 1.000000
palworld-server  | PLAYER_DAMAGE_RATE_DEFENSE = 1.000000
palworld-server  | PLAYER_STOMACH_DECREACE_RATE = 1.000000
palworld-server  | PLAYER_STAMINA_DECREACE_RATE = 1.000000
palworld-server  | PLAYER_AUTO_HPREGENE_RATE = 1.000000
palworld-server  | PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP = 1.000000
palworld-server  | PAL_STOMACH_DECREACE_RATE = 1.000000
palworld-server  | PAL_STAMINA_DECREACE_RATE = 1.000000
palworld-server  | PAL_AUTO_HPREGENE_RATE = 1.000000
palworld-server  | PAL_AUTO_HP_REGENE_RATE_IN_SLEEP = 1.000000
palworld-server  | BUILD_OBJECT_DAMAGE_RATE = 1.000000
palworld-server  | BUILD_OBJECT_DETERIORATION_DAMAGE_RATE = 1.000000
palworld-server  | COLLECTION_DROP_RATE = 1.000000
palworld-server  | COLLECTION_OBJECT_HP_RATE = 1.000000
palworld-server  | COLLECTION_OBJECT_RESPAWN_SPEED_RATE = 1.000000
palworld-server  | ENEMY_DROP_ITEM_RATE = 1.000000
palworld-server  | DEATH_PENALTY = All
palworld-server  | ENABLE_PLAYER_TO_PLAYER_DAMAGE = False
palworld-server  | ENABLE_FRIENDLY_FIRE = False
palworld-server  | ENABLE_INVADER_ENEMY = True
palworld-server  | ACTIVE_UNKO = False
palworld-server  | ENABLE_AIM_ASSIST_PAD = True
palworld-server  | ENABLE_AIM_ASSIST_KEYBOARD = False
palworld-server  | DROP_ITEM_MAX_NUM = 3000
palworld-server  | DROP_ITEM_MAX_NUM_UNKO = 100
palworld-server  | BASE_CAMP_MAX_NUM = 128
palworld-server  | BASE_CAMP_WORKER_MAX_NUM = 15
palworld-server  | DROP_ITEM_ALIVE_MAX_HOURS = 1.000000
palworld-server  | AUTO_RESET_GUILD_NO_ONLINE_PLAYERS = False
palworld-server  | AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS = 72.000000
palworld-server  | GUILD_PLAYER_MAX_NUM = 20
palworld-server  | PAL_EGG_DEFAULT_HATCHING_TIME = 72.000000
palworld-server  | WORK_SPEED_RATE = 1.000000
palworld-server  | IS_MULTIPLAY = False
palworld-server  | IS_PVP = False
palworld-server  | CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP = False
palworld-server  | ENABLE_NON_LOGIN_PENALTY = True
palworld-server  | ENABLE_FAST_TRAVEL = True
palworld-server  | IS_START_LOCATION_SELECT_BY_MAP = True
palworld-server  | EXIST_PLAYER_AFTER_LOGOUT = False
palworld-server  | ENABLE_DEFENSE_OTHER_GUILD_PLAYER = False
palworld-server  | COOP_PLAYER_MAX_NUM = 4
palworld-server  | SERVER_PLAYER_MAX_NUM = 16
palworld-server  | SERVER_NAME = "World of Pals"
palworld-server  | SERVER_DESCRIPTION = "Dit is een Test"
palworld-server  | ADMIN_PASSWORD = "adminPasswordHere"
palworld-server  | SERVER_PASSWORD = "Test 123 ofpals"
palworld-server  | PUBLIC_PORT = 8211
palworld-server  | PUBLIC_IP = ""
palworld-server  | RCON_ENABLED = true
palworld-server  | RCON_PORT = 25575
palworld-server  | REGION = ""
palworld-server  | USE_AUTH = True
palworld-server  | BAN_LIST_URL = "https://api.palworldgame.com/api/banlist.txt"
palworld-server  | ====Debug====
palworld-server  | *****STARTING SERVER*****
palworld-server  | ./PalServer.sh -port=8211 -queryport=27015 -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS
palworld-server  | [S_API] SteamAPI_Init(): Loaded local 'steamclient.so' OK.
palworld-server  | Shutdown handler: initalize.
palworld-server  | Increasing per-process limit of core file size to infinity.
palworld-server  | CAppInfoCacheReadFromDiskThread took 8 milliseconds to initialize
palworld-server  | Setting breakpad minidump AppID = 2394010
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.

In Game: image

It also seems to accept any password as long as there is one set

thijsvanloef avatar Jan 30 '24 20:01 thijsvanloef

Initial testing does not seem very succesfull, all PalWorldSettings.ini are set correctly, however it does not seem to work ingame: PalWorldSettings.ini

This is more likely a problem with the formatting of the ini file, all settings may need to be on one line.

The values are reaching the ini file, which is a really good sign for this method. Now we just need to get the ini formatted correctly so that the server picks up the settings properly.

Twinki14 avatar Jan 30 '24 22:01 Twinki14

Some considerations:

  • Should i keep the debug output?
  • What kind of naming do i use for envronment variables?

In my opinion,

  • Let's always output the environment variables, it's very useful information to have and imo a informational level, not debug level. Outputting the full ini after compilation would also be a bonus - anyone looking at logs is already seeking to find information about something going wrong, so I see no reason to keep the env var logging specific to a "debug output" toggle
  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • DayTimeSpeedRate -> DAY_TIME_SPEED_RATE,
    • bIsPvP -> B_IS_PVP
    • Prefixing each environment variable with PALWORLD_SERVER_ might be smart, if we want to support "other" ini sections, but I don't think it's worthwhile
    • This would set us up nicely for the future if we ever wanted to automate the creation of the setting compilation script, we could read settings from a DefaultPalworldSettings.ini, and easily convert each setting to a environment variable counterpart

Twinki14 avatar Jan 30 '24 22:01 Twinki14

Hey thanks for testing! I wonder why it is not formatting correctly. I'm using tr to remove all the new lines. Might be a tooling difference between macos and linux? I'll check.

  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • ...
    • bIsPvP -> B_IS_PVP

I'd maybe remove type identifiers like b :)

  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • ...
    • Prefixing each environment variable with PALWORLD_SERVER_ might be smart, if we want to support "other" ini sections, but I don't think it's worthwhile

I don't like prefixing them. Some of those variables are already super long which would make it more unreadable.

  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • ...
    • This would set us up nicely for the future if we ever wanted to automate the creation of the setting compilation script, we could read settings from a DefaultPalworldSettings.ini, and easily convert each setting to a environment variable counterpart

I like that idea!

MSpreckels avatar Jan 31 '24 06:01 MSpreckels

As we talked about in discord: Ive now fixed the replacement of \n line ending to \n\r line ending. This still works on my end. I've also replaced some env vars that i set with some that already been set before.

Please test this, thoroughly.

MSpreckels avatar Jan 31 '24 16:01 MSpreckels

I've done some initial testing and everything seems to work! Will test more thoroughly tomorrow. Thank you for all the work!

thijsvanloef avatar Jan 31 '24 19:01 thijsvanloef

Is this pushed to dev? @thijsvanloef

chkpwd avatar Jan 31 '24 19:01 chkpwd

I'd maybe remove type identifiers like b :)

I only included the modifier with the idea that eventually we'll have an automation script for the compilation script, identifying and dropping type identifiers might add to the logic complexity for such a script, but that is only an eventual idea.

I'm not partial in any direction.

Twinki14 avatar Jan 31 '24 20:01 Twinki14

@chkpwd no, but you can test it locally by checking out this branch and running: docker build --tag thijsvanloef/palworld-server-docker:latest And then running compose up

thijsvanloef avatar Jan 31 '24 20:01 thijsvanloef

Some final thoughts on this, and these are just my opinions

  • After this is merged, the next release should bump from 0.19.1 to 0.50.0, this PR should solidify how we're going to support server settings for probably awhile, and will override anyone's current custom ini's, this will very much be a big breaking change
  • If we agree on this, if we wait spend some time waiting before the 0.50.0 release, I can update the helm chart & example docker compose to instead use the "last compatible version" instead of latest, remove custom ini support, and remove the k8s manifests
  • The readme should also be updated in the timeframe between sitting in main and release

Twinki14 avatar Jan 31 '24 20:01 Twinki14

Since we define the default values in the compile-settings if the game updates and changes one of the default values then no one running the image would have the updated default values until we update the compile-settings file and they update their image.

If a value isn't defined the ini file then game seems to use the default value.

Dashboy1998 avatar Feb 01 '24 01:02 Dashboy1998

Since we define the default values in the compile-settings if the game updates and changes one of the default values then no one running the image would have the updated default values until we update the compile-settings file and they update their image.

If a value isn't defined the ini file then game seems to use the default value.

Hence why an automation script would be very valuable. A scheduled GitHub Action can regularly run, start a Palworld server, copy the DefaultPalworldSettings.ini, run an automation script against it, and then output the full compilation script with all default values.

Twinki14 avatar Feb 01 '24 02:02 Twinki14

Since we define the default values in the compile-settings if the game updates and changes one of the default values then no one running the image would have the updated default values until we update the compile-settings file and they update their image. If a value isn't defined the ini file then game seems to use the default value.

Hence why an automation script would be very valuable. A scheduled GitHub Action can regularly run, start a Palworld server, copy the DefaultPalworldSettings.ini, run an automation script against it, and then output the full compilation script with all default values.

Why not create the compilation script at container start up instead?

Dashboy1998 avatar Feb 01 '24 03:02 Dashboy1998

Why not create the compilation script at container start up instead?

It needs a DefaultPalworldSettings.ini, which if it's populated when the server is installed from steamcmd, this might be doable. But I think keeping it outside the container will be better, for documentation purposes

Twinki14 avatar Feb 01 '24 03:02 Twinki14

  • After this is merged, the next release should bump from 0.19.1 to 0.50.0, this PR should solidify how we're going to support server settings for probably awhile, and will override anyone's current custom ini's, this will very much be a big breaking change

I really dont like that. We are in active early development, changes like that are to be expected. We should test the case when someone is using a save from previous versions and upgrades to a latest image where this change is implemented, so that we know what is going to happen. Maybe we can check for custom values in ini? 0.20.0 is sufficient IMO.

If a value isn't defined the ini file then game seems to use the default value.

Thats a good point, somehow I've never tried that.

Why not create the compilation script at container start up instead?

What do you mean by container start up? Do you mean in the init script? when the docker container is being build?

MSpreckels avatar Feb 01 '24 06:02 MSpreckels

In the start script read values in default ini to create the config script.

Been trying to find a good tool that let's you modify ini but none seem to support arrays.

Dashboy1998 avatar Feb 01 '24 07:02 Dashboy1998

In the start script read values in default ini to create the config script.

Been trying to find a good tool that let's you modify ini but none seem to support arrays.

Thats the thing. Pocket Pair's decision on making a giant array instead of separated values makes this so much harder.

MSpreckels avatar Feb 01 '24 07:02 MSpreckels

Have to agree with @MSpreckels on the new tag, jumping the tag to 0.50 will probably not make any difference to 0.20 People who are on latest will update People who fixed it on v0 tag will update People who fixed it on v0.19 will not update People who fixed it on v0.19.1 will not update

The only thing I will add is a breaking change warning in the release.

thijsvanloef avatar Feb 01 '24 09:02 thijsvanloef

When do you plan to merge this?

iamspido avatar Feb 06 '24 08:02 iamspido

@iamspido @MSpreckels Initial testing resulted in no errors, will resume testing tomorrow and probably release tomorrow :)

thijsvanloef avatar Feb 06 '24 19:02 thijsvanloef

Did some more testing today, was not able to find any errors, @MSpreckels once merge conflict has been resolved, ready to merge :)

thijsvanloef avatar Feb 07 '24 15:02 thijsvanloef

I don't know if that was planned, but the environment variable BASE_CAMP_WORKER_MAXNUM has been changed to BASE_CAMP_WORKER_MAX_NUM. By setting BASE_CAMP_WORKER_MAX_NUM: "20" it has no effect, and you're still limited to the default of 15. However, the value 20 is correctly set in the palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.

iamspido avatar Feb 08 '24 00:02 iamspido