Files
gocryptotrader/gctscript/vm/vm_task.go
Ryan O'Hara-Reid db8735ec99 log: Add structured logging (#1171)
* basic implementation

* log: deprecate duplicate function, add tests and refine calls.

* linter: fixes

* linter: update struct

* linter and new type

* log tests: update to not lint issue

* linter: stop complaining please

* glorious: nits

* log: rm comment code

* glorious: nits

* glorious: nits

* glorious: nits

* glorious: nits missed

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2023-05-10 17:52:53 +10:00

31 lines
463 B
Go

package vm
import (
"time"
"github.com/thrasher-corp/gocryptotrader/log"
)
func (vm *VM) runner() {
vm.S = make(chan struct{}, 1)
waitTime := time.NewTicker(vm.T)
vm.NextRun = time.Now().Add(vm.T)
go func() {
for {
select {
case <-waitTime.C:
vm.NextRun = time.Now().Add(vm.T)
err := vm.RunCtx()
if err != nil {
log.Errorln(log.GCTScriptMgr, err)
return
}
case <-vm.S:
waitTime.Stop()
return
}
}
}()
}