remove env
This commit is contained in:
parent
180baa1bb2
commit
f85da9b418
@ -20,4 +20,4 @@ WORKDIR /app/
|
|||||||
COPY --from=builder /app/gottdad .
|
COPY --from=builder /app/gottdad .
|
||||||
|
|
||||||
# Command to run the executable
|
# Command to run the executable
|
||||||
CMD ["./gottdad"]
|
CMD ["./gottdad -config /app/data/config.json"]
|
1
go.mod
1
go.mod
@ -3,7 +3,6 @@ module git.siteop.biz/shoopea/gottdad
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ianschenck/envflag v0.0.0-20140720210342-9111d830d133
|
|
||||||
github.com/tidwall/pretty v1.2.0
|
github.com/tidwall/pretty v1.2.0
|
||||||
gopkg.in/tucnak/telebot.v2 v2.4.0
|
gopkg.in/tucnak/telebot.v2 v2.4.0
|
||||||
)
|
)
|
||||||
|
2
go.sum
2
go.sum
@ -1,7 +1,5 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/ianschenck/envflag v0.0.0-20140720210342-9111d830d133 h1:h6FO/Da7rdYqJbRYMW9f+SMBWnJVguWh+0ERefW8zp8=
|
|
||||||
github.com/ianschenck/envflag v0.0.0-20140720210342-9111d830d133/go.mod h1:pyYc5lldRtL0l5YitYVv1dLKuC0qhMfAfiR7BLsN2pA=
|
|
||||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
27
main.go
27
main.go
@ -5,20 +5,15 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
"github.com/ianschenck/envflag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfg *Config
|
cfg *Config
|
||||||
srv *ServerTTD
|
srv *ServerTTD
|
||||||
bot *Bot
|
bot *Bot
|
||||||
configFile string
|
|
||||||
|
|
||||||
configFlag = flag.String("config", "", "config file")
|
configFlag = flag.String("config", "config.json", "config file")
|
||||||
initFlag = flag.Bool("init", false, "init config")
|
initFlag = flag.Bool("init", false, "init config")
|
||||||
configEnv = envflag.String("CONFIG", "", "config file")
|
|
||||||
initEnv = envflag.Bool("INIT", false, "init config")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -26,23 +21,15 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *configFlag != "" {
|
|
||||||
configFile = *configFlag
|
|
||||||
} else if *configEnv != "" {
|
|
||||||
configFile = *configEnv
|
|
||||||
} else {
|
|
||||||
configFile = "config.json"
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg = &Config{}
|
cfg = &Config{}
|
||||||
if *initFlag || *initEnv {
|
if *initFlag {
|
||||||
logInfoWarn("Initializing configuration..")
|
logInfoWarn("Initializing configuration..")
|
||||||
err = cfg.Init()
|
err = cfg.Init()
|
||||||
failError(err, "Cannot init config")
|
failError(err, "Cannot init config")
|
||||||
err = cfg.Save(configFile)
|
err = cfg.Save(*configFlag)
|
||||||
failError(err, "Cannot save config")
|
failError(err, "Cannot save config")
|
||||||
} else {
|
} else {
|
||||||
err = cfg.Load(configFile)
|
err = cfg.Load(*configFlag)
|
||||||
failError(err, "Cannot open config")
|
failError(err, "Cannot open config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
ttd.go
2
ttd.go
@ -143,7 +143,7 @@ func (s *ServerTTD) HeartBeat(stop chan struct{}) {
|
|||||||
} else if s.Status.Paused && !s.NeedPause() {
|
} else if s.Status.Paused && !s.NeedPause() {
|
||||||
s.Unpause()
|
s.Unpause()
|
||||||
}
|
}
|
||||||
cfg.Save(configFile)
|
cfg.Save(*configFlag)
|
||||||
time.Sleep(updateHeartBeat)
|
time.Sleep(updateHeartBeat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||||
package main
|
package main
|
||||||
var githash = "1fba5c6"
|
var githash = "180baa1"
|
||||||
var buildstamp = "2021-11-06_16:13:18"
|
var buildstamp = "2021-11-06_16:24:55"
|
||||||
var commits = "158"
|
var commits = "161"
|
||||||
var version = "1fba5c6-b158 - 2021-11-06_16:13:18"
|
var version = "180baa1-b161 - 2021-11-06_16:24:55"
|
||||||
|
Loading…
Reference in New Issue
Block a user