Setting and updating an environment variable for the gl-user-server

In order for my game server process to run on amazon’s gamelift server instance an environment variable needs to be set for the user running the game server executable. This happens to be the gl-user-server. Amazon has provided a seemingly well suited solution for initial setup in the form of the install.sh script that is automatically run when the fleet is being set up.

The install script is run by the gl-user-installer user which sets an environment variable for the gl-user-server user with a line like this:

echo “export LD_LIBRARY_PATH=/local/game/Data/Plugins/x86_64” | sudo tee --append /home/gl-user-server/.bash_profile

The problem is that after the environment variable has been written to the gl-user-server’s .bash_profile by the gl-user-installer, the gl-user-server needs to reload it’s profile. However, as of yet I have been unable to find a way for the gl-user-installer to force the gl-user-server to reload in order to get the updated profile.

Does anyone have any ideas on this?

Hi @BrokenBirdie, this might be it:

From https://forum.unity.com/threads/unity-linux-plugin-depending-on-third-party-library-dllnotfoundexception.467175/

"Linux is a bit different than some other platforms in that the directory a library is loaded from isn’t automatically part of the library search path. So if you have libMyPlugin.so and libThingMyPluginNeeds.so in the same directory, you won’t be able to dynamically load MyPlugin unless the directory where ThingMyPluginNeeds lives has been added to the library loader path (usually via the LD_LIBRARY_PATH environment variable).

We’ve tried to ameliorate this in recent Unity releases (5.6+ iirc) by attempting to preload libraries from the Plugins folder, so that any plugin dependencies can be loaded, as long as their dependencies are loadable. (You should get output like Preloaded ‘ScreenSelector.so’.)

For plugins you build yourself, you can also resolve this by setting a runtime path for your plugin when you link it. For example, when using gcc, you can add -Wl,-rpath=’$ORIGIN’ to your link line. This will make the loader look for linked libraries in the same directory where your library lives.

To diagnose loader issues, you can run ldd libMyPlugin.so to see where its dependencies will be loaded from by default. You can also run Unity or your player with MONO_LOG_LEVEL=debug MONO_LOG_MASK=dll set in your environment, so that Unity will log diagnostic information about what’s happening with respect to native plugin loading."

I would try adding the library path to your player build settings. Also, I am not a Unity expert, so Unity support may have additional perspective on this.

Thank you,
Al Murray :slight_smile:
Solutions Architect, Amazon Game Tech

Thanks for the response Al.

I have looked at this thread before but unfortunately in this specific case the library path has to be set manually, it is a known issue of the plugin we are using.