Comments (3)
You should be able to achieve this by using Fds.Listener and Fds.AddListener.
Pseudo-code:
ln, _ := upg.Fds.Listener("systemd", "something")
if ln == nil {
// Get ln from systemd, probably via os.NewFile / net.FileListener
upg.Fds.AddListener("systemd", "something", ln)
}
from tableflip.
@matthewmueller did you have any luck with the above?
from tableflip.
@lmb, hey sorry for the late response! I want to say I tried this but wasn't able to get it working. I ended up sticking nginx in front for now.
I'll close this for now because I have something that's working, but I'll probably give this another shot at a later time because I just love that it's a single binary system.
If it's helpful to anyone else, here's my findings.
From the socket activation side it looks like this:
file := os.NewFile(uintptr(3), "socket")
ln, err := net.FileListener(file)
if err != nil {
panic(err)
}
// serve, and somehow get it working with tableflip
And here's a test app that could simulate socket activation:
ln, err := net.Listen("tcp", ":8000")
if err != nil {
panic(err)
}
file, err := ln.(*net.TCPListener).File()
if err != nil {
panic(err)
}
cmd := exec.Command("go", "run", "main.go")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.ExtraFiles = append(cmd.ExtraFiles, file)
// serve from the other file
if err := cmd.Run(); err != nil {
panic(err)
}
I think the ideal situation would be to say systemctl reload app
and have it somehow do the upgrade, rolling back if there's been a failure. This might not make sense with socket activation in which case it might make more sense to just add capabilities to the systemd unit file for the protected port and call it the way godoc suggests.
Like I mentioned, I wasn't able to get this working nicely, but I'd love for someone else to take the lead!
from tableflip.
Related Issues (20)
- supervisord HOT 4
- [Question] Windows HOT 4
- Expose parent presence
- sometimes got error like "listen tcp xxx: bind: address already in use" when Upgrade HOT 4
- support unix socket HOT 2
- Logs go missing after systemd-journald restart HOT 2
- How to integrate with systemd and supervisor? HOT 2
- Impossible to build for windows HOT 2
- Add an example for supervisord integration HOT 1
- Enable SO_REUSEPORT HOT 1
- Allow multiple back-to-back graceful upgrades HOT 1
- Request for updating README.MD HOT 1
- Keep foreground control with signal propagation after successful upgrade HOT 5
- Hello, is https not supported? HOT 1
- upg.Exit() do not effective in go routine ? HOT 1
- [Bug] Connections not closed on inherited net.Conn HOT 2
- Can't catch syscall.SIGINT after upgrade HOT 1
- how can i use it for rpcx restart
- Overseer HOT 3
- Upgrade function documentation
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 tableflip.