feat(update): add update deployment via web UI
- Deploy exe to alternate port 5033 - Current instance keeps running - Add parallel mode and addr flag - Add update panel to web UI - Update OpenAPI spec and CLI
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"net"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
PortPrimary = 5032
|
||||
PortAlternate = 5033
|
||||
UpdatesSubdir = "updates"
|
||||
)
|
||||
|
||||
// AlternateListenAddr returns the other blue-green port (5032 <-> 5033).
|
||||
func AlternateListenAddr(current string) (string, error) {
|
||||
host, portStr, err := net.SplitHostPort(current)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if host == "" {
|
||||
host = "0.0.0.0"
|
||||
}
|
||||
port, err := strconv.Atoi(portStr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
next := PortAlternate
|
||||
if port == PortAlternate {
|
||||
next = PortPrimary
|
||||
}
|
||||
return net.JoinHostPort(host, strconv.Itoa(next)), nil
|
||||
}
|
||||
|
||||
func UpdatesDir() (string, error) {
|
||||
base, err := InstallDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(base, UpdatesSubdir), nil
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAlternateListenAddr(t *testing.T) {
|
||||
next, err := AlternateListenAddr("0.0.0.0:5032")
|
||||
if err != nil || next != "0.0.0.0:5033" {
|
||||
t.Fatalf("5032 -> %q, %v", next, err)
|
||||
}
|
||||
next, err = AlternateListenAddr("0.0.0.0:5033")
|
||||
if err != nil || next != "0.0.0.0:5032" {
|
||||
t.Fatalf("5033 -> %q, %v", next, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user