Comments (13)
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.
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.
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.
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.
PR are always welcome, and if they are to document, even better!
from s6-overlay.
@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, 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.
@smebberson That should work - exec only clears the environment when you use the -c
switch.
from s6-overlay.
@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.
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.
@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.
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.
My previous post suggests two ways of achieving what you want.
from s6-overlay.
Related Issues (20)
- systemd notify service conversion exmaple HOT 4
- s6-notifyoncheck: fatal: s6-supervise not running. HOT 3
- Installing S6 on official php-fpm container shows no log output from S6 HOT 5
- Issue with s6-overlay in Cattr project when deployed on Kubernetes HOT 6
- `UID not set` error HOT 10
- Question: pass args to the underlying service HOT 6
- s6-overlay v3 only sends SIGTERM to `/etc/services.d` after `S6_SERVICES_GRACETIME` HOT 8
- Setting S6_READ_ONLY_ROOT does not copy `/etc` to `/run/s6/etc` HOT 3
- Service is started, but reported as "normally down", seemingly by default HOT 11
- 3.1.6.1 hangs at the very end of shutdown for more than a minute HOT 3
- In some rare occasions s6-overlay hangs at shutdown for undefined amount of time HOT 4
- Using s6-overlay with ECS Exec HOT 8
- How to create something similar like cont-init if this one is deprecated ? HOT 3
- Best practice for redirecting output from app1 to app2 HOT 5
- Problem using S6_STAGE2_HOOK to run shell script HOT 2
- s6-linux-init: warning: parent wrote to fd 3! HOT 9
- How to read ENV variables from a file for the main process (defined in CMD) HOT 4
- Shutdown container during s6-rc startup leads to deadlock HOT 3
- finish script does not receive system.exit code but 0 HOT 33
- Cannot make Log to stdout work with s6-overlay 3.1.6.2 (no bug, just looking for some guidance/help). HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s6-overlay.