Commit 55518ade authored by Anatolie Lupacescu's avatar Anatolie Lupacescu Committed by GitHub

feat: time based warning (#2158)

parent d4aeb344
...@@ -10,7 +10,9 @@ BEELOCAL_BRANCH ?= main ...@@ -10,7 +10,9 @@ BEELOCAL_BRANCH ?= main
BEEKEEPER_BRANCH ?= master BEEKEEPER_BRANCH ?= master
COMMIT ?= "$(shell git describe --long --dirty --always --match "" || true)" COMMIT ?= "$(shell git describe --long --dirty --always --match "" || true)"
LDFLAGS ?= -s -w -X github.com/ethersphere/bee.commit="$(COMMIT)" CLEAN_COMMIT ?= "$(shell git describe --long --always --match "" || true)"
COMMIT_TIME ?= "$(shell git show -s --format=%ct $(CLEAN_COMMIT) || true)"
LDFLAGS ?= -s -w -X github.com/ethersphere/bee.commit="$(COMMIT)" -X github.com/ethersphere/bee.CommitTime="$(COMMIT_TIME)"
.PHONY: all .PHONY: all
all: build lint vet test-race binary all: build lint vet test-race binary
......
...@@ -55,6 +55,8 @@ func (c *command) initStartCmd() (err error) { ...@@ -55,6 +55,8 @@ func (c *command) initStartCmd() (err error) {
return fmt.Errorf("new logger: %v", err) return fmt.Errorf("new logger: %v", err)
} }
go startTimeBomb(logger)
isWindowsService, err := isWindowsService() isWindowsService, err := isWindowsService()
if err != nil { if err != nil {
return fmt.Errorf("failed to determine if we are running in service: %w", err) return fmt.Errorf("failed to determine if we are running in service: %w", err)
...@@ -80,34 +82,31 @@ func (c *command) initStartCmd() (err error) { ...@@ -80,34 +82,31 @@ func (c *command) initStartCmd() (err error) {
} }
beeASCII := ` beeASCII := `
Welcome to Swarm.... Bzzz Bzzzz Bzzzz Welcome to Swarm.... Bzzz Bzzzz Bzzzz
\ / \ /
\ o ^ o / \ o ^ o /
\ ( ) / \ ( ) /
____________(%%%%%%%)____________ ____________(%%%%%%%)____________
( / / )%%%%%%%( \ \ ) ( / / )%%%%%%%( \ \ )
(___/___/__/ \__\___\___) (___/___/__/ \__\___\___)
( / /(%%%%%%%)\ \ ) ( / /(%%%%%%%)\ \ )
(__/___/ (%%%%%%%) \___\__) (__/___/ (%%%%%%%) \___\__)
/( )\ /( )\
/ (%%%%%) \ / (%%%%%) \
(%%%) (%%%)
! ` ! `
fmt.Println(beeASCII) fmt.Println(beeASCII)
fmt.Print(` fmt.Print(`
DISCLAIMER: DISCLAIMER:
This software is provided to you "as is", use at your own risk and without warranties of any kind. This software is provided to you "as is", use at your own risk and without warranties of any kind.
It is your responsibility to read and understand how Swarm works and the implications of running this software. It is your responsibility to read and understand how Swarm works and the implications of running this software.
The usage of Bee involves various risks, including, but not limited to: The usage of Bee involves various risks, including, but not limited to:
damage to hardware or loss of funds associated with the Ethereum account connected to your node. damage to hardware or loss of funds associated with the Ethereum account connected to your node.
No developers or entity involved will be liable for any claims and damages associated with your use, No developers or entity involved will be liable for any claims and damages associated with your use,
inability to use, or your interaction with other nodes or the software. inability to use, or your interaction with other nodes or the software.`)
`)
logger.Infof("version: %v", bee.Version) fmt.Printf("\n\nversion: %v - planned to be supported until %v, please follow http://ethswarm.org/\n\n", bee.Version, endSupportDate())
debugAPIAddr := c.config.GetString(optionNameDebugAPIAddr) debugAPIAddr := c.config.GetString(optionNameDebugAPIAddr)
if !c.config.GetBool(optionNameDebugAPIEnable) { if !c.config.GetBool(optionNameDebugAPIEnable) {
...@@ -119,6 +118,8 @@ inability to use, or your interaction with other nodes or the software. ...@@ -119,6 +118,8 @@ inability to use, or your interaction with other nodes or the software.
return err return err
} }
logger.Infof("version: %v", bee.Version)
bootNode := c.config.GetBool(optionNameBootnodeMode) bootNode := c.config.GetBool(optionNameBootnodeMode)
fullNode := c.config.GetBool(optionNameFullNode) fullNode := c.config.GetBool(optionNameFullNode)
......
package cmd
import (
"strconv"
"time"
"github.com/ethersphere/bee"
"github.com/ethersphere/bee/pkg/logging"
)
const (
limitDays = 90
warningDays = 0.9 * limitDays // show warning once 90% of the time bomb time has passed
sleepFor = 30 * time.Minute
)
var (
commitTime, _ = strconv.ParseInt(bee.CommitTime, 10, 64)
versionReleased = time.Unix(commitTime, 0)
)
func startTimeBomb(logger logging.Logger) {
for {
outdated := time.Now().AddDate(0, 0, -limitDays)
if versionReleased.Before(outdated) {
logger.Warning("your node is outdated, please check for the latest version")
} else {
almostOutdated := time.Now().AddDate(0, 0, -warningDays)
if versionReleased.Before(almostOutdated) {
logger.Warning("your node is almost outdated, please check for the latest version")
}
}
<-time.After(sleepFor)
}
}
func endSupportDate() string {
return versionReleased.AddDate(0, 0, limitDays).Format("2 January 2006")
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
package bee package bee
var CommitTime string
var ( var (
version = "1.0.0" // manually set semantic version number version = "1.0.0" // manually set semantic version number
commit string // automatically set git commit hash commit string // automatically set git commit hash
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment