-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(p2p): add --foreground flag to listen and forward commands #11099
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
base: master
Are you sure you want to change the base?
Conversation
adds `-f/--foreground` option that keeps the command running until interrupted (SIGTERM/Ctrl+C) or closed via `ipfs p2p close`. the listener/forwarder is automatically removed when the command exits. useful for systemd services and scripts that need cleanup on exit.
34a8acc to
e7bb812
Compare
|
Thanks! This works great for me I have two ipfs services, one to launch ipfs as a daemon and one to start forwarding ssh in the background. ipfs.service ipfs-ssh-forward.service This seems to work really nicely with systemd, the port listening will automatically restart with if for some reason that systemd service stops running and will relaunch with the ipfs service when it starts. Only quirk is I'm depending on delays to wait for ipfs daemon to fully startup before launching p2p listen. If there a file that gets created/modified when the daemon fully starts it could be tracked with one of the path directives in systemd (https://www.freedesktop.org/software/systemd/man/latest/systemd.path.html#PathExists=) Can't really comment to much on the code to implement this as I'm not familiar with the code base or go-lang in general EDIT: |
|
@Hazematman you could also use |
|
I'm still testing it for robustness but this is what I have now for systemd services I have a ipfs-ssh-forward.service unit file that looks like Then I have a ipfs-ssh-forward.path systemd path file I'm using the ipfs.service basically unmodified described here https://github.com/ipfs/kubo/tree/master/misc Then to enable things I do The ipfs service should startup and then once the The one weird thing I'm trying to debug is that it seems that the first launch of the ipfs-ssh-forward service always fails. I'm not 100% sure why but one theory is that when the api file is created, ipfs isn't ready for p2p listen commands yet. |
adds
-f/--foregroundoption that keeps the command running until interrupted (SIGTERM/Ctrl+C) or closed viaipfs p2p close. the listener/forwarder is automatically removed when the command exits.useful for systemd services and scripts that need cleanup on exit.