Skip to content
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

fix docker service stop #480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nicbus
Copy link

@nicbus nicbus commented Feb 2, 2024

This PR changes the order in which services are stopped when the docker container is shut down.

With the previous order (based on ls output) I was getting the following logs:

shutting down container
4-2024-02-01T22:07:20Z tor: Thread interrupt
4-2024-02-01T22:07:20Z Shutdown: In progress...
4-2024-02-01T22:07:20Z RemoveLocal(g4xk3jxhqac4qqexdrnhk2mnd4c6dnmufvt4mifkwiyipvq7xzj5i3qd.onion:18444)
4-2024-02-01T22:07:20Z opencon thread exit
4-2024-02-01T22:07:20Z torcontrol thread exit
4-2024-02-01T22:07:20Z addcon thread exit
4-2024-02-01T22:07:20Z net thread exit
4-2024-02-01T22:07:20Z msghand thread exit
2-2024-02-01T22:07:20.430+00:00 - WARN - reconnecting to bitcoind: failed to read cookie from "/data/bitcoin/regtest/.cookie"
2-2024-02-01T22:07:23.431+00:00 - WARN - failed to connect daemon at 127.0.0.1:18443: Connection refused (os error 111)
2-2024-02-01T22:07:26.431+00:00 - WARN - failed to connect daemon at 127.0.0.1:18443: Connection refused (os error 111)
kill: run: bitcoin: (pid 75) 35s, want down, got TERM
2-2024-02-01T22:07:27.660+00:00 - TRACE - stop accepting new RPCs
2-2024-02-01T22:07:27.660+00:00 - TRACE - closing 0 RPC connections
2-2024-02-01T22:07:27.660+00:00 - TRACE - RPC connections are closed
2-2024-02-01T22:07:27.660+00:00 - TRACE - RPC server is stopped
2-2024-02-01T22:07:27.660+00:00 - ERROR - server failed: Error: Iterrupted by signal 15
2-   0: <unknown>
2-   1: <unknown>
2-   2: <unknown>
2-   3: <unknown>
2-   4: <unknown>
2-   5: <unknown>
2-   6: <unknown>
2-   7: <unknown>
2-   8: <unknown>
2-   9: <unknown>
2-  10: __libc_start_main
2-  11: <unknown>
2-
2-
2-2024-02-01T22:07:27.662+00:00 - TRACE - deregistering event source from poller
ok: down: electrs: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: prerenderer: 0s, normally up
ok: down: socat: 1s, normally up
ok: down: tor: 0s, normally up

Also, when starting the container again, bitcoind was always resuming from height 0, instead of the one it was at before the stop was requested.

With the change in this PR I am getting:

shutting down container
ok: down: nginx: 0s, normally up
6-Feb 01 22:11:19.000 [notice] Catching signal TERM, exiting cleanly.
4-2024-02-01T22:11:19Z RemoveLocal(3z4bdbvidw6aq46z7gxkj6nrvfukatdw4bvlyh2lakz5ranswsga3jad.onion:18444)
ok: down: tor: 1s, normally up
ok: down: socat: 0s, normally up
ok: down: websocket: 0s, normally up
ok: down: prerenderer: 1s, normally up
ok: down: electrs: 0s, normally up
ok: down: bitcoin: 1s, normally up

Also, when starting the container again, bitcoind resumes from the height it was before the stop was requested.

Notes:

  • tested using bitcoin-regtest
  • I also took the liberty to address some (shellcheck) lint warnings

@shesek
Copy link
Collaborator

shesek commented Feb 13, 2024

Thanks for the PR!

If I understand correctly, the necessary change is to have electrs shut down prior to bitcoin, right?

Perhaps it would be easier to explicitly issue a force-stop to electrs first, then iterate over the services in the directory? That way there's no need to maintain an updated list of services in the script and no need to check for a diff.

@nicbus
Copy link
Author

nicbus commented Feb 14, 2024

Only stopping the required services is better indeed. It's not just electrs though, so I made more tests and isolated socat as well (which needs to be stopped first).

Updated and rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants