Auto updater APIs (#1523)

* APIs for querying and executing an update in place.

For #924

* Use the process pid to query systemd for status

* Use parent pid and invocation ID to guess if running from systemd

* Stream cmd output to client + report errors

* Update comment to refer to INVOCATION_ID
This commit is contained in:
Gabe Kangas
2021-11-30 13:15:18 -08:00
committed by GitHub
parent 71abb3cfb5
commit 83eb9229ad
6 changed files with 229 additions and 5 deletions

View File

@@ -34,6 +34,9 @@ var GitCommit = ""
// BuildPlatform is the optional platform this release was built for.
var BuildPlatform = "dev"
// EnableAutoUpdate will explicitly enable in-place auto-updates via the admin.
var EnableAutoUpdate = false
// GetCommit will return an identifier used for identifying the point in time this build took place.
func GetCommit() string {
if GitCommit == "" {
@@ -53,9 +56,9 @@ const MaxSocketPayloadSize = 2048
// GetReleaseString gets the version string.
func GetReleaseString() string {
var versionNumber = VersionNumber
var buildPlatform = BuildPlatform
var gitCommit = GetCommit()
versionNumber := VersionNumber
buildPlatform := BuildPlatform
gitCommit := GetCommit()
return fmt.Sprintf("Owncast v%s-%s (%s)", versionNumber, buildPlatform, gitCommit)
}

View File

@@ -0,0 +1,8 @@
//go:build enable_updates
// +build enable_updates
package config
func init() {
EnableAutoUpdate = true
}