Skip to content

Commit

Permalink
Do not download daemon JAR on dev versions
Browse files Browse the repository at this point in the history
  • Loading branch information
boazy committed Jan 1, 2020
1 parent be7ca86 commit afb6132
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plummy-cli/daemon/daemon_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func Ensure(args *StartupArgs) Daemon {
}
d := Find()
if d == nil || !d.IsAlive() {
if jar == nil {
log.Fatalf("No JAR file found for version %v. Please use a release version or start the daemon manually.", args.Version)
}
d = start(jar)
} else if shouldRestart(d, jar) {
// Restart the daemon if user asked for a different version a different version
Expand Down Expand Up @@ -102,10 +105,18 @@ func restart(oldDaemon Daemon, newDaemonJar *installer.Resource) Daemon {
return start(newDaemonJar)
}

func shouldRestart(oldDaemon Daemon, newDaemonJar *installer.Resource) bool {
v := oldDaemon.Version()
func shouldRestart(runningDaemon Daemon, newDaemonJar *installer.Resource) bool {
// If no alternative JAR is specified we should not restart the daemon anyway
if newDaemonJar == nil {
return false
}

// If we can't determine the running daemon version, we should restart
v := runningDaemon.Version()
if v == nil {
return true
}

// If running daemon is not the same version as the new daemon, restart
return !v.Equal(newDaemonJar.Version())
}
4 changes: 4 additions & 0 deletions plummy-cli/installer/plummy_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func EnsurePlummyDaemon(versionStr string) (*Resource, error) {
if err != nil {
return nil, fmt.Errorf("bad pluumy version '%s' format: %w", versionStr, err)
}
if version.Prerelease() == "dev" {
// We cannot find a jar file for development version versions
return nil, nil
}
if d := FindPlummyDaemon(version); d != nil {
return d, nil
}
Expand Down

0 comments on commit afb6132

Please sign in to comment.