Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
No WS server running in stage2, lets handle this with redirecting
Browse files Browse the repository at this point in the history
ws.SendMsg to log.Println
  • Loading branch information
kmoore134 committed May 19, 2019
1 parent 0021cd8 commit 65e8157
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions defines/defines.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var TrainsUrl string
// Default kernel pkg name
var KernelPkg string

// Are we running without WS backend
var DisableWSMsg = false

// Set our default bootstrap options
var Bootstrap = false
var BootstrapFatal = false
Expand Down
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ func main() {
// Update any variable locations
defines.SetLocs()

// Bypass normal startup and go straight to updating
if defines.Stage2Flag {
update.StartStage2()
os.Exit(0)
}

// Capture any sigint
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
Expand Down Expand Up @@ -236,11 +242,6 @@ func main() {
os.Exit(0)
}

if defines.Stage2Flag {
update.StartStage2()
os.Exit(0)
}

if defines.WebsocketFlag {
go startws(done)
log.Println("Listening on", defines.WebsocketAddr)
Expand Down
4 changes: 3 additions & 1 deletion update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,6 @@ func startupgrade(kernelupdate bool) {

func preparestage2() {
log.Println("Preparing to start update...")
logger.LogToFile("Preparing to start stage2 update....")

// Need to ensure ZFS is all mounted and ready
cmd := exec.Command("mount", "-u", "rw", "/")
Expand Down Expand Up @@ -990,6 +989,9 @@ func preparestage2() {

func StartStage2() {

// No WS server to talk to
defines.DisableWSMsg = true

preparestage2()

doupdatefilemnt("")
Expand Down
4 changes: 4 additions & 0 deletions ws/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type JSONReply struct {
}

func SendMsg(msg string, msg_type ...string) {
if defines.DisableWSMsg {
log.Println(msg)
return
}
m_type := "info"

if len(msg_type) > 0 {
Expand Down

0 comments on commit 65e8157

Please sign in to comment.