Skip to content

Commit

Permalink
Merge pull request #112 from mysteriumnetwork/version-1.0.48
Browse files Browse the repository at this point in the history
Version 1.0.48
  • Loading branch information
Zensey committed Apr 19, 2024
2 parents 1544594 + e6a7552 commit 0c89434
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 28 deletions.
4 changes: 2 additions & 2 deletions cmd/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (

var (
// fixed non-string version. used for launcher version checks
intVersion = [4]uint16{1, 0, 47, 0}
intVersion = [4]uint16{1, 0, 48, 0}
// display version
strVersion = "1.0.47"
strVersion = "1.0.48"
)

func getIcon(path string) *winres.Icon {
Expand Down
37 changes: 23 additions & 14 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,25 @@ func NewController(m *model.UIModel, ui model.Gui_, a model.AppState) *Controlle
func (c *Controller) Start() {
//c.lg.Println("start")

restartBackendControl := func() {
restartBackendControl := func(afterInstall bool) {
fmt.Println("restartBackendControl>")

if c.runner != nil {
c.stopBackendControl()
fmt.Println("restartBackendControl stop>")
c.stopBackendControl(afterInstall)
fmt.Println("restartBackendControl stop>>>")
}
c.runner = NewBackend(c.model.Config.Backend, c.model, c.ui)

c.model.SwitchState(model.UIStateInitial)
c.startBackendControl()
}
restartBackendControl()
c.model.Bus2.Subscribe("backend", restartBackendControl)
restartBackendControl(false)

onBackendChange := func() {
restartBackendControl(false)
}
c.model.Bus2.Subscribe("backend", onBackendChange)

c.model.UIBus.SubscribeAsync("install-dlg-exit", func(id int) {
fmt.Println("install-dlg-exit>", id, c.model.State)
Expand All @@ -66,7 +74,7 @@ func (c *Controller) Start() {
case model.UIStateInstallFinished:
c.model.SwitchState(model.UIStateInitial)
// restart controller as it stops after installation
restartBackendControl()
restartBackendControl(true)

case model.UIStateInstallError:
c.ui.CloseUI()
Expand All @@ -88,7 +96,7 @@ func (c *Controller) Start() {

func (c *Controller) Shutdown() {
c.lg.Println("Shutdown >")
c.stopBackendControl()
c.stopBackendControl(false)

// TODO: unsubscribe
}
Expand All @@ -99,10 +107,12 @@ func (c *Controller) TriggerAction(action string) {

/////////////////////////////////////////////////////////////////////////

func (c *Controller) stopBackendControl() {
func (c *Controller) stopBackendControl(afterInstall bool) {
c.lg.Println("stop")

c.action <- model.ActionStop
if !afterInstall {
c.action <- model.ActionStop
}
c.wg.Wait()
}

Expand All @@ -119,10 +129,9 @@ func (c *Controller) startBackendControl() {
}
// now we have runtime (docker) running

hasUpdates := false
if !c.waitForShutdownReady {
hasUpdates = c.runner.CheckCurrentVersionAndUpgrades(false)
}
// if !c.waitForShutdownReady {
// }
hasUpdates := c.runner.CheckCurrentVersionAndUpgrades(false)

if !c.runner.IsRunning() {
if c.model.Config.AutoUpgrade && hasUpdates {
Expand All @@ -131,7 +140,6 @@ func (c *Controller) startBackendControl() {
}

c.runner.StartContainer()
c.lg.Println("startNode >", c.model.Config.AutoUpgrade, hasUpdates)

if c.model.Config.AutoUpgrade && hasUpdates {

Expand All @@ -158,7 +166,7 @@ func (c *Controller) startBackendControl() {
startNode()

case act := <-c.action:
// log.Println("<-", act)
log.Println("<-", act)

switch act {
case model.ActionCheck:
Expand All @@ -180,6 +188,7 @@ func (c *Controller) startBackendControl() {

case model.ActionStop:
c.runner.StopContainer()
log.Println("<- exit")
return

case model.ActionDisable:
Expand Down
32 changes: 24 additions & 8 deletions controller/docker/install_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,40 @@ import (
"bytes"
"fmt"

"github.com/mysteriumnetwork/myst-launcher/ctrl/util"
"github.com/mysteriumnetwork/myst-launcher/model"
"github.com/mysteriumnetwork/myst-launcher/utils"
"github.com/mysteriumnetwork/myst-launcher/platform"

)

func (c *Controller) tryInstallDocker() {
fmt.Println("TryInstallDocker>")

func (c *Docker_) TryInstallRuntime_() {

if c.model.Config.InitialState.Not1Not2() {
c.lg.Println("TryInstallRuntime_ !!!!2>")

c.model.SwitchState(model.UIStateInstallNeeded)

} else {
// begin install immediately
c.TryInstallRuntime()
}
}

func (c *Docker_) TryInstallRuntime() bool {
fmt.Println("TryInstallRuntime>")

mdl := c.model
ui := c.ui
//ui := c.ui
mgr, _ := platform.NewManager()
name := "Docker.dmg"

mdl.ResetProperties()
mdl.SwitchState(model.UIStateInstallInProgress)

executor := util.NewStepExecutor(mdl)
executor := NewStepExecutor(mdl)
executor.AddStep("CheckVTx", func() bool {
featuresOK, err := c.mgr.Features()
featuresOK, err := mgr.Features()
if err != nil {
c.lg.Println("Failed to query feature:", err)
return false
Expand All @@ -56,7 +73,6 @@ func (c *Controller) tryInstallDocker() {
})

executor.AddStep("DownloadFiles", func() bool {
name := "Docker.dmg"
url, err := utils.GetDockerDesktopLink()
if err != nil {
c.lg.Println("Couldn't get Docker Desktop link")
Expand All @@ -77,7 +93,7 @@ func (c *Controller) tryInstallDocker() {

executor.AddStep("InstallDocker", func() bool {
var buf bytes.Buffer
_, err = utils.CmdRun(&buf, "/usr/sbin/diskutil", "unmount", "/Volumes/Docker")
_, err := utils.CmdRun(&buf, "/usr/sbin/diskutil", "unmount", "/Volumes/Docker")
if err != nil {
c.lg.Println("Failed to run command:", err)
return false
Expand Down
10 changes: 6 additions & 4 deletions controller/native/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b
exename := getNodeProcessName()
fullpath := utils.MakeCanonicalPath(path.Join(c.runner.binpath, exename))

fileAbsent := false
file, err := os.Stat(fullpath)
if err != nil {
cfg.NodeExeVersion = ""
cfg.NodeExeTimestamp = time.Time{}
fileAbsent = true
} else {
modTime := file.ModTime()
if !modTime.Equal(cfg.NodeExeTimestamp) {
Expand All @@ -83,6 +85,7 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b
doRefresh := cfg.NodeExeVersion == "" || cfg.NodeExeLatestTag == "" ||
cfg.TimeToCheckUpgrade() ||
refreshVersionCache ||
fileAbsent ||
doUpgrade

if !doRefresh {
Expand All @@ -104,9 +107,9 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b
setUi()

doUpgrade_ := hasUpdate() && doUpgrade
log.Println("CheckAndUpgradeNodeExe doUpgrade>", doUpgrade_)
log.Println("CheckAndUpgradeNodeExe doUpgrade>", hasUpdate(), doUpgrade_)

if doUpgrade_ {
if doUpgrade_ || fileAbsent {
p, _ := utils.IsProcessRunningExt(exename, fullpath)
if p != 0 {
utils.TerminateProcess(p, 0)
Expand All @@ -124,8 +127,7 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b

return true
}

return doUpgrade_
return hasUpdate()
}

// returns: will exit
Expand Down

0 comments on commit 0c89434

Please sign in to comment.