-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: new option à la --replace
to leverage this existing feature in a docker restart
context
#594
Comments
--replace
to be leverage this latter option in docker restart
context--replace
to leverage this existing feature in a docker restart
context
I am not sure the executable itself can do anything in the case when it is containerised in this way (I don't understand what Maybe the new option would help with the management of stored state during such transitions ? |
Hi @AltGr, thanks a lot for your comment! Indeed, the overall aim is to have a Dockerised server with minimal downtime. I agree that this may be possible to implement this by using a Docker Swarm or Kubernetes balancer, several instances sharing the
So my idea was to support a similar CLI option, to offer this high-availability feature easily within the app's logic, namely:
→ What do you think? Have a nice WE! |
I didn't think about this (it's another topic!): maybe there will also be sth to do to get a safer |
Ah! I understand better your intent. |
Hi @AltGr! Mostly yes, this could work. (Except that Actually when Docker entrypoints come into play, I believe it's always slightly better to avoid spinning a shell, to ensure that the entrypoint binary always receives proper signals (see e.g. https://hynek.me/articles/docker-signals/) So, what do we decide? Option 1. Just keep learn-ocaml CLI as is, and change the Docker entrypoint. (I downvote this one because of signals.) And if ever Option 2. or 3. looks good to you, would you prefer to implement it, or to review the PR ? :) |
After reading https://hynek.me/articles/docker-signals/ I still think signals should work, since we already use dumb-init... it may be worth testing anyway. Otherwise no strong objection to option 3 (maybe with a more high-level name than |
Thanks @AltGr !
AFAIU, it would be very OK if the shell is ephemeral (using the
Sure, I can volunteer to do more tests.
OK, good point.
OK. Would you have a few suggestions in mind, regarding the things to monitor ? maybe, with a dedicated tool ? And do you think that the potentiel weird things that can occur would be specific to the forking ? or would they already occur with the current implementation of Have a very nice WE! |
Ah indeed, the Dockerfile I'm still pretty sure it can be done... but the balance of which approach is simplest might be changed :) As long as you fork before running |
Motivation: - Makes it possible to provide a feature similar to the `--replace` option (namely, `learn-ocaml build serve --replace`) within a Docker context. As `--replace` needed to successively start 2 learn-ocaml processes listening to the same port, but if we spin two different containers, ./www is not shared between containers, nor the local TCP interface. - If tweaking the default entrypoint could be an alternative solution, the shell script would be involved to cope with the need to handle signals properly. - The solution implemented in this patch is simpler and can be enabled in a docker-compose context by passing: ``` environment: LEARNOCAML_SERVE_DURING_BUILD: 'true' ``` then run a command such as `docker restart learn-ocaml`. Remarks: - Using docker-compose, to restart a server and benefit from this feature, use ( docker compose stop ; docker compose restart ) rather than ( docker compose down ; docker compose up -d ) - This commit has been double-checked with both native server ( make ; make opaminstall ; learn-ocaml build serve --serve-during-build --repo=$REPO ) and bytecode server ( make ; make opaminstall ; mv $(which learn-ocaml-server){,~} ; learn-ocaml build serve --serve-during-build --repo=$REPO ) Close ocaml-sf#594
Motivation: - Makes it possible to provide a feature similar to the `--replace` option (namely, `learn-ocaml build serve --replace`) within a Docker context. As `--replace` needed to successively start 2 learn-ocaml processes listening to the same port, but if we spin two different containers, ./www is not shared between containers, nor the local TCP interface. - If tweaking the default entrypoint could be an alternative solution, the shell script would be involved to cope with the need to handle signals properly. - The solution implemented in this commit is simpler and can be enabled in a docker-compose context by passing: ``` environment: LEARNOCAML_SERVE_DURING_BUILD: 'true' ``` or: ``` environment: - 'LEARNOCAML_SERVE_DURING_BUILD=true' ``` then run a command such as `docker restart learn-ocaml`. Remarks: - Using docker-compose, to restart a server and benefit from this feature, use ( docker compose stop ; docker compose restart ) rather than ( docker compose down ; docker compose up -d ) - This commit has been double-checked with both native server ( make ; make opaminstall ; learn-ocaml build serve --serve-during-build --repo=$REPO ) and bytecode server ( make ; make opaminstall ; mv $(which learn-ocaml-server){,~} ; learn-ocaml build serve --serve-during-build --repo=$REPO ) - For uniformity, this commit also introduces an environment variable 'LEARNOCAML_REPLACE=true' as a fallback for `--replace`. Close ocaml-sf#594
Motivation: - Makes it possible to provide a feature similar to the `--replace` option (namely, `learn-ocaml build serve --replace`) within a Docker context. As `--replace` needed to successively start 2 learn-ocaml processes listening to the same port, but if we spin two different containers, ./www is not shared between containers, nor the local TCP interface. - If tweaking the default entrypoint could be an alternative solution, the shell script would be involved to cope with the need to handle signals properly. - The solution implemented in this commit is simpler and can be enabled in a docker-compose context by passing: ``` environment: LEARNOCAML_SERVE_DURING_BUILD: 'true' ``` or: ``` environment: - 'LEARNOCAML_SERVE_DURING_BUILD=true' ``` then run a command such as `docker restart learn-ocaml`. Remarks: - Using docker-compose, to restart a server and benefit from this feature, use ( docker compose stop ; docker compose restart ) rather than ( docker compose down ; docker compose up -d ) - This commit has been double-checked with both native server ( make ; make opaminstall ; learn-ocaml build serve --serve-during-build --repo=$REPO ) and bytecode server ( make ; make opaminstall ; mv $(which learn-ocaml-server){,~} ; learn-ocaml build serve --serve-during-build --repo=$REPO ) - For uniformity, this commit also introduces an environment variable 'LEARNOCAML_REPLACE=true' as a fallback for `--replace`. Close ocaml-sf#594
Motivation: - Makes it possible to provide a feature similar to the `--replace` option (namely, `learn-ocaml build serve --replace`) within a Docker context. As `--replace` needed to successively start 2 learn-ocaml processes listening to the same port, but if we spin two different containers, ./www is not shared between containers, nor the local TCP interface. - If tweaking the default entrypoint could be an alternative solution, the shell script would be involved to cope with the need to handle signals properly. - The solution implemented in this commit is simpler and can be enabled in a docker-compose context by passing: ``` environment: LEARNOCAML_SERVE_DURING_BUILD: 'true' ``` or: ``` environment: - 'LEARNOCAML_SERVE_DURING_BUILD=true' ``` then run a command such as `docker restart learn-ocaml`. Remarks: - Using docker-compose, to restart a server and benefit from this feature, use ( docker compose stop ; docker compose restart ) rather than ( docker compose down ; docker compose up -d ) - This commit has been double-checked with both native server ( make ; make opaminstall ; learn-ocaml build serve --serve-during-build --repo=$REPO ) and bytecode server ( make ; make opaminstall ; mv $(which learn-ocaml-server){,~} ; learn-ocaml build serve --serve-during-build --repo=$REPO ) - For uniformity, this commit also introduces an environment variable 'LEARNOCAML_REPLACE=true' as a fallback for `--replace`. Close ocaml-sf#594
Motivation: - Makes it possible to provide a feature similar to the `--replace` option (namely, `learn-ocaml build serve --replace`) within a Docker context. As `--replace` needed to successively start 2 learn-ocaml processes listening to the same port, but if we spin two different containers, ./www is not shared between containers, nor the local TCP interface. - If tweaking the default entrypoint could be an alternative solution, the shell script would be involved to cope with the need to handle signals properly. - The solution implemented in this commit is simpler and can be enabled in a docker-compose context by passing: ``` environment: LEARNOCAML_SERVE_DURING_BUILD: 'true' ``` or: ``` environment: - 'LEARNOCAML_SERVE_DURING_BUILD=true' ``` then run a command such as `docker restart learn-ocaml`. Remarks: - Using docker-compose, to restart a server and benefit from this feature, use ( docker compose stop ; docker compose restart ) rather than ( docker compose down ; docker compose up -d ) - This commit has been double-checked with both native server ( make ; make opaminstall ; learn-ocaml build serve --serve-during-build --repo=$REPO ) and bytecode server ( make ; make opaminstall ; mv $(which learn-ocaml-server){,~} ; learn-ocaml build serve --serve-during-build --repo=$REPO ) - For uniformity, this commit also introduces an environment variable 'LEARNOCAML_REPLACE=true' as a fallback for `--replace`. Close ocaml-sf#594
Related user(s):
@erikmd, @AltGr
Related issue(s) or PR(s):
--replace
option #567Related project scope(s):
No response
The problem:
learn-ocaml build serve --replace
is very nice 💯(anyway, there's the 1-proc-per-container rule!)
docker compose restart
, and we would really like to benefit from the--replace
semantics in this caseWanted solution:
--replace
, e.g.--fork-replace
, or--smooth-replace
Considered alternatives:
--replace
, e.g.--fork
or--quick-restart
)--fork
is passed without--replace
)Additional context:
We should think about ENV VARS as well! (e.g., a single environment variable that can be set to
{}="0", "1" or "2"
)The text was updated successfully, but these errors were encountered: