Jump to content

Environment Variables


Adolfram

Recommended Posts

  • Moderators
1 minute ago, Adolfram said:

I'm afraid it is not. I've set up a docker environment for my dev/prod servers and the only way I can distinguish dev and prod is the ports.

There is no global Lua environment afaik, atleast not that I am aware of. Each resource has it's own environment.

But that doesn't mean a resource can't get information through http.

If you want MTA to native support custom Lua env. variables, you probably need to create a module or modify MTA itself.

 

 

 

  • Like 1
Link to comment
On 08/11/2020 at 13:09, Adolfram said:

I'm afraid it is not. I've set up a docker environment for my dev/prod servers and the only way I can distinguish dev and prod is the ports.

 

Actually I've made a simple native server module for exactly this purpose - to pass some configuration or secrets via env variables to the MTA server running in docker container. There is a "getSystemEnvVariable(string variableName)" function there (no "set" counterpart as I didn't need it, but could be implemented easily). Currently I haven't published any releases of .dll / .so but the code is available on Github and you can build it yourself easily: https://github.com/4O4/mta-ml-sysutils

Generic building instruction is: run "utils/premake5 gmake && cd Build && make" on linux, and on windows run: "utils/premake5.exe vs2019" and then open Build/*.sln file in visual studio and launch build from there. After a successful build the dll / so will be in Bin/ folder.  If you need help with building or want me to publish binaries built by me on github releases, just let me know.

This module also includes a second utility function "executeSystemCommand(string systemCommand, function commandFinishedCallback(exitCode, stdout, stderr))" for executing system commands asynchronously in a separate thread, although I ended up not using it very much so I don't know about its stability. Should work but no guarantees, I'm just informing you that it exists in the same module and that's why it is called "sysutils".

  • Like 2
Link to comment
  • 3 weeks later...
On 12/11/2020 at 17:17, 4O4 said:

 

Actually I've made a simple native server module for exactly this purpose - to pass some configuration or secrets via env variables to the MTA server running in docker container. There is a "getSystemEnvVariable(string variableName)" function there (no "set" counterpart as I didn't need it, but could be implemented easily). Currently I haven't published any releases of .dll / .so but the code is available on Github and you can build it yourself easily: https://github.com/4O4/mta-ml-sysutils

Generic building instruction is: run "utils/premake5 gmake && cd Build && make" on linux, and on windows run: "utils/premake5.exe vs2019" and then open Build/*.sln file in visual studio and launch build from there. After a successful build the dll / so will be in Bin/ folder.  If you need help with building or want me to publish binaries built by me on github releases, just let me know.

This module also includes a second utility function "executeSystemCommand(string systemCommand, function commandFinishedCallback(exitCode, stdout, stderr))" for executing system commands asynchronously in a separate thread, although I ended up not using it very much so I don't know about its stability. Should work but no guarantees, I'm just informing you that it exists in the same module and that's why it is called "sysutils".

Hey, thanks a lot! This should do.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...