Skip to content

Commit

Permalink
01) reverted addition of UpdateFrequencySeconds to the README - this …
Browse files Browse the repository at this point in the history
…was already a default value and is fine at default

02) removed all time.Duration values from config.go after learning how to convert ints to time.Duration with time.Duration()... this fixes issue #25

03) fixed an issue where updater was using the delay between iterations from the profiler

04) fixed an issue where updater_test was using the delay between iterations from the profiler
  • Loading branch information
seantcanavan committed Dec 19, 2016
1 parent 11303d2 commit b3add93
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Clients can also use [go-dos-yourself](https://github.com/seantcanavan/go-dos-yo
2. CheckInGmailPassword - set this to the password to the above gmail address.
3. CheckInFrequencySeconds - set this to the frequency at which you'd like to receive system reports at your specified email address. value is in seconds.
4. NetQueryFrequencySeconds - set this to the frequency at which you'd like anon-eth-net to check for internet connectivity.
5. UpdateFrequencySeconds - set this to the frequency at which you'd like anon-eth-net to check for updates to itself.
2. Optionally update the optional values in assets/config.json:
1. DeviceName - set this to the canonical name of the device which will be executing anon-eth-net. e.g. "main desktop", "garage pc", "sister's laptop", etc.
2. DeviceId - if you wish to use your own method of uniquely identifying your remote devices fill in that value here otherwise anon-eth-net will generate a GUID for you automatically.
Expand Down
1 change: 0 additions & 1 deletion src/github.com/seantcanavan/assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"CheckInGmailPassword" : "yourgmailpasswordhere",
"CheckInFrequencySeconds" : 3600,
"NetQueryFrequencySeconds" : 3600,
"UpdateFrequencySeconds": 3600,

"DeviceName" : "My Little Raspberry Pi",
"DeviceId" : "aa3b2cd6-7a95-4b2a-af33-7eb953d730a9"
Expand Down
5 changes: 2 additions & 3 deletions src/github.com/seantcanavan/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"math/rand"
"strconv"
"strings"
"time"

"github.com/nu7hatch/gouuid"
"github.com/seantcanavan/logger"
Expand All @@ -30,8 +29,8 @@ var Cfg *Config
type Config struct {
CheckInGmailAddress string `json:"CheckInGmailAddress"` // (R) the gmail address to send updates to and receive updates from. parsed from line 1 of CheckInEmailCredentialsFile
CheckInGmailPassword string `json:"CheckInGmailPassword"` // (R) the password for the gmail account. parsed from line 2 of CheckInEmailCredentialsFile
CheckInFrequencySeconds time.Duration `json:"CheckInFrequencySeconds"` // (R) The frequency with which this program will send status updates. In seconds.
NetQueryFrequencySeconds time.Duration `json:"NetQueryFrequencySeconds"` // (R) The frequency with which this program will attempt to connect to the outside world to verify internet connectivity
CheckInFrequencySeconds int `json:"CheckInFrequencySeconds"` // (R) The frequency with which this program will send status updates. In seconds.
NetQueryFrequencySeconds int `json:"NetQueryFrequencySeconds"` // (R) The frequency with which this program will attempt to connect to the outside world to verify internet connectivity
DeviceName string `json:"DeviceName"` // (O) The canonical DeviceName for the machine currently executing this program.
DeviceId string `json:"DeviceId"` // (O) The unique ID for the machine currently executing this program.
InitialStartup string `json:"InitialStartup"` // (D) Whether or not this is the first time that the program is starting.
Expand Down
2 changes: 1 addition & 1 deletion src/github.com/seantcanavan/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (con *Network) Run() {

interval := config.Cfg.NetQueryFrequencySeconds

logger.Lgr.LogMessage("Network manager will sleep for %d seconds before querying the internet", config.Cfg.NetQueryFrequencySeconds)
logger.Lgr.LogMessage("Network manager will sleep for %d seconds before querying the internet", interval)

time.Sleep(time.Duration(interval) * time.Second)

Expand Down
6 changes: 3 additions & 3 deletions src/github.com/seantcanavan/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func Run() {

go func() {

for 1 == 1 {
for 1 == 1 {

logger.Lgr.LogMessage("waiting for updates. sleeping %v", config.Cfg.CheckInFrequencySeconds)
time.Sleep(config.Cfg.CheckInFrequencySeconds * time.Second)
logger.Lgr.LogMessage("waiting for updates. sleeping %v", config.Cfg.UpdateFrequencySeconds)
time.Sleep(time.Duration(config.Cfg.UpdateFrequencySeconds) * time.Second)

local := config.Cfg.LocalVersion
remote, remoteErr := remoteVersion()
Expand Down
2 changes: 1 addition & 1 deletion src/github.com/seantcanavan/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestVersionCompare(t *testing.T) {

func TestRun(t *testing.T) {

config.Cfg.CheckInFrequencySeconds = 2
config.Cfg.UpdateFrequencySeconds = 2
Run()
time.Sleep(time.Second * 6)

Expand Down

0 comments on commit b3add93

Please sign in to comment.