Replies: 4 comments 9 replies
-
Hmm, that does sound nuts!
Good question, I'm not really familiar with this docker stuff.
You could try this completely untested patch, it should leave Unit running after its initial startup/config. diff --git a/pkg/docker/docker-entrypoint.sh b/pkg/docker/docker-entrypoint.sh
index 4646409f..3c3e95fd 100755
--- a/pkg/docker/docker-entrypoint.sh
+++ b/pkg/docker/docker-entrypoint.sh
@@ -76,26 +76,10 @@ if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then
curl_put /usr/share/unit/welcome/welcome.json "config"
fi
- echo "$0: Stopping Unit daemon after initial configuration..."
- kill -TERM $(/bin/cat /var/run/unit.pid)
-
- for i in $(/usr/bin/seq $WAITLOOPS); do
- if [ -S /var/run/control.unit.sock ]; then
- echo "$0: Waiting for control socket to be removed..."
- /bin/sleep $SLEEPSEC
- else
- break
- fi
- done
- if [ -S /var/run/control.unit.sock ]; then
- kill -KILL $(/bin/cat /var/run/unit.pid)
- rm -f /var/run/control.unit.sock
- fi
-
echo
- echo "$0: Unit initial configuration complete; ready for start up..."
+ echo "$0: Unit initial configuration complete"
echo
+
+ exit 0
fi
fi
-
-exec "$@" |
Beta Was this translation helpful? Give feedback.
-
Hi @Tenzer
Hmm, is it normal to not run an init(1) process in a container? |
Beta Was this translation helpful? Give feedback.
-
Hi @Tenzer Thanks for reporting this. As you can see this is an "challenge" we are currently actively investigating and we are about to enhance. What @lcrilly already mentioned - you are good to use Units state directory for now and see if this will speed up your container startup (it should) OR to make the state part of the docker build process and populate this into the state. |
Beta Was this translation helpful? Give feedback.
-
I understand that dynamically configuring unit via a control socket is some fundamental design decision, but am I wrong to think that it does complicate matters when running in containers? I am trying to replace nginx + python-app server runner with unit for our deployments in kubernetes, and we have restrictions such as a read-only filesystem (except /tmp, which is mounted on startup and thus cannot be populated during build), can't run the main pod process as root, and must be able to configure things like client max body size for a deployment (i.e., it cannot be built into the image). With nginx, we could just create a config file from environment variables in the entrypoint, then launch nginx with that config file. To do the same with unit, unit must be started as a daemon, then configured via control socket, then killed, then started again. I understand this may not be what you intended and may even be architecturally difficult, but I feel like it would be much simpler if one could have the option of simply starting unit from the command line with a config file - without a control socket, e.g., |
Beta Was this translation helpful? Give feedback.
-
Hi
I am currently evaluating using Unit for a Python WSGI application, and I've found the Docker containers with Unit to be pretty slow to start up.
Part of this is down to the Python application being sizable and the number of processes we are running, but it's only made worse by the
docker-entrypoint.sh
script, which loads in the configuration for the application from/docker-entrypoint.sh/
into Unit, which then starts the application with the number of processes we want, then shuts down Unit for it to then have to go through the work again.Is there any good reason for Unit to be restarted?
Could we instead place our configuration in
/var/lib/unit/
to avoid this extra work?Beta Was this translation helpful? Give feedback.
All reactions