summaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/xdsserver.go
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-10-01 11:51:47 +0200
committerClément Bénier <clement.benier@iot.bzh>2018-10-16 14:57:58 +0200
commit5e979f0ba451e64fc44ffaa8b79d714d9ad75a57 (patch)
tree6fb6ba51e034ba361fd833b482fb061d4f918da7 /lib/xdsserver/xdsserver.go
parent4982769bd48b5c67c5eff4d9c6f297fa2a7531a4 (diff)
update xds-server package in docker
scripts/package-update: bash scripts to update xds-server package in docker monitor updates: default time is 24h, a update is tried at startup api/v1: 2 new requests: - get(updates): return various information about xds-server packages - post(updates): update xds-server packages Change-Id: I1673f7860e57cfe1d4abe5a24609ee46a90b67d8 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'lib/xdsserver/xdsserver.go')
-rw-r--r--lib/xdsserver/xdsserver.go50
1 files changed, 28 insertions, 22 deletions
diff --git a/lib/xdsserver/xdsserver.go b/lib/xdsserver/xdsserver.go
index 1079eba..e96ab57 100644
--- a/lib/xdsserver/xdsserver.go
+++ b/lib/xdsserver/xdsserver.go
@@ -37,22 +37,23 @@ const cookieMaxAge = "3600"
// Context holds the XDS server context
type Context struct {
- ProgName string
- Cli *cli.Context
- Config *xdsconfig.Config
- Log *logrus.Logger
- LogLevelSilly bool
- LogSillyf func(format string, args ...interface{})
- SThg *st.SyncThing
- SThgCmd *exec.Cmd
- SThgInotCmd *exec.Cmd
- mfolders *Folders
- sdks *SDKs
- targets *Targets
- WWWServer *WebServer
- sessions *Sessions
- events *Events
- Exit chan os.Signal
+ ProgName string
+ Cli *cli.Context
+ Config *xdsconfig.Config
+ Log *logrus.Logger
+ LogLevelSilly bool
+ LogSillyf func(format string, args ...interface{})
+ SThg *st.SyncThing
+ SThgCmd *exec.Cmd
+ SThgInotCmd *exec.Cmd
+ mfolders *Folders
+ sdks *SDKs
+ targets *Targets
+ WWWServer *WebServer
+ sessions *Sessions
+ events *Events
+ lockXdsSrvUpdate LockXdsUpdate
+ Exit chan os.Signal
}
// NewXdsServer Create a new instance of XDS server
@@ -83,12 +84,13 @@ func NewXdsServer(cliCtx *cli.Context) *Context {
// Define default configuration
ctx := Context{
- ProgName: cliCtx.App.Name,
- Cli: cliCtx,
- Log: log,
- LogLevelSilly: logSilly,
- LogSillyf: sillyFunc,
- Exit: make(chan os.Signal, 1),
+ ProgName: cliCtx.App.Name,
+ Cli: cliCtx,
+ Log: log,
+ LogLevelSilly: logSilly,
+ LogSillyf: sillyFunc,
+ lockXdsSrvUpdate: LockXdsUpdate{LockCpt: 0},
+ Exit: make(chan os.Signal, 1),
}
// register handler on SIGTERM / exit
@@ -206,6 +208,10 @@ func (ctx *Context) Run() (int, error) {
// Sessions manager
ctx.sessions = ClientSessionsConstructor(ctx, cookieMaxAge)
+ // Check if a new package version is available
+ // and monitor updates
+ MonitorUpdates(ctx)
+
// Run Web Server until exit requested (blocking call)
if err = ctx.WWWServer.Serve(); err != nil {
ctx.Log.Println(err)