Coder Social home page Coder Social logo

Comments (13)

glerchundi avatar glerchundi commented on August 22, 2024 2

with-contenv is the way to go. It was coded with execline in mind (chaining processes) but it can be used with other kind of scripting languages of course!

Try this:

#!/usr/bin/with-contenv sh

# cd into our directory
cd /app

# start our node.js application
exec node server.js;

from s6-overlay.

skarnet avatar skarnet commented on August 22, 2024 2

Yes, there's a 4096 byte limit for variables loaded via s6-envdir. This is intentional: most legitimate uses of the environment never transmit large quantities of data. You can put the data in a temporary file, put the name of the file in an environment variable, and make your application get its data from the file.

Alternatively, you could recompile skalibs, then s6 after increasing the limit here: [http://git.skarnet.org/cgi-bin/cgit.cgi/skalibs/tree/src/libstddjb/envdir.c#n12] but it will not be standard and you will need to maintain the patch.

from s6-overlay.

smebberson avatar smebberson commented on August 22, 2024 1

Awesome, that works perfectly :)

Do you think this is worth adding to the documentation, the README? I'd be happy to submit a PR with this....

from s6-overlay.

smebberson avatar smebberson commented on August 22, 2024

Just wanted to add that when I run a script through docker exec everything works fine, the environment variables exist. But when the script is run through s6, they don't.

from s6-overlay.

glerchundi avatar glerchundi commented on August 22, 2024

PR are always welcome, and if they are to document, even better!

from s6-overlay.

smebberson avatar smebberson commented on August 22, 2024

@glerchundi, also, am I correct in thinking that in your example, node would also have the same environment variables despite the fact it was exec'd?

Alright, I'll get to work!

from s6-overlay.

glerchundi avatar glerchundi commented on August 22, 2024

@glerchundi, also, am I correct in thinking that in your example, node would also have the same environment variables despite the fact it was exec'd?

yeah, i think so: http://ss64.com/bash/exec.html

from s6-overlay.

jprjr avatar jprjr commented on August 22, 2024

@smebberson That should work - exec only clears the environment when you use the -c switch.

from s6-overlay.

smebberson avatar smebberson commented on August 22, 2024

@glerchundi, just to be clear, for documentation purposes.

From reading the code, if I have a script that sets environment variables using setenv or export this won't make it's way into the /var/run/s6/container_environment directory... I could be wrong?

If they don't, that means running a script with #!/usr/bin/with-contenv sh won't pick up the new environment variables... how should one go about doing this kind of thing with s6-overlay?

from s6-overlay.

glerchundi avatar glerchundi commented on August 22, 2024

You're correct. In runtime you can make it available if you create a file (naming it with your desired env name) and fill it with your custom value. Something like this: printf "YOURVALUE" > /var/run/s6/container_environment/YOURENV.

That should do the trick.

from s6-overlay.

apratina avatar apratina commented on August 22, 2024

@glerchundi @jprjr @smebberson @skarnet : using with-contenv bash we are unable to use any environment variable of length greater than 4096 char. Is this a known issue?
I have created a very simple way to repro it. Check here.

from s6-overlay.

VINAYJAGANNATH avatar VINAYJAGANNATH commented on August 22, 2024

Can the limit of 4096 bytes made configurable ?
If yes this would give us great flexibility to inject environment variables which have higher than 4096 bytes.
We have a use case for this, Where in Cloud Foundry all the service bindings are injected as part of ENV and we have no control over the injection to the init process.
We tried using S6-Overlay as init process and due to this limit the all the service binding properties are no injected to the application process which is managed by S6-Overlay.

from s6-overlay.

skarnet avatar skarnet commented on August 22, 2024

My previous post suggests two ways of achieving what you want.

from s6-overlay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.