@@ -69,17 +69,12 @@ func main() {
69
69
handler := logger (http .HandlerFunc (loadAndHandle ))
70
70
71
71
// If running under systemd, listen on 80 and 443 and serve TLS.
72
- if listeners , _ := activation .Listeners (); len (listeners ) == 2 {
73
- // Want listeners[0] is port 80, listeners[1] is port 443.
74
- // There's no guaranteed order of the listeners!
75
- // Sometimes we get 80, 443; other times we get 443, 80.
76
- names := strings .Split (os .Getenv ("LISTEN_FDNAMES" ), ":" )
77
- if strings .Contains (names [0 ], "https" ) {
78
- listeners [0 ], listeners [1 ] = listeners [1 ], listeners [0 ]
79
- }
72
+ if listeners , _ := activation .ListenersWithNames (); len (listeners ) == 2 {
73
+ httpListener := listeners ["vcweb-http.socket" ][0 ]
74
+ httpsListener := listeners ["vcweb-https.socket" ][0 ]
80
75
81
76
go func () {
82
- log .Fatal (http .Serve (listeners [ 0 ] , handler ))
77
+ log .Fatal (http .Serve (httpListener , handler ))
83
78
}()
84
79
dir := acme .LetsEncryptURL
85
80
if * staging {
@@ -115,7 +110,7 @@ func main() {
115
110
daemon .SdNotify (false , "WATCHDOG=1" )
116
111
}
117
112
}()
118
- log .Fatal (s .ServeTLS (listeners [ 1 ] , "" , "" ))
113
+ log .Fatal (s .ServeTLS (httpsListener , "" , "" ))
119
114
}
120
115
121
116
// Local development on :8088.
0 commit comments