X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsserver%2Fxdsserver.go;h=1079ebafb83606271e512f8b24c9d269827c17d6;hb=f870de867b43bfb1220067f81c11395438fb2863;hp=64041b940a73dcf757ee15eb7d639b1ae96ebba2;hpb=963931e04d44a5b40d38817163f52f56241a9f33;p=src%2Fxds%2Fxds-server.git diff --git a/lib/xdsserver/xdsserver.go b/lib/xdsserver/xdsserver.go index 64041b9..1079eba 100644 --- a/lib/xdsserver/xdsserver.go +++ b/lib/xdsserver/xdsserver.go @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 "IoT.bzh" + * Copyright (C) 2017-2018 "IoT.bzh" * Author Sebastien Douheret * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,12 +26,11 @@ import ( "syscall" "time" + st "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/syncthing" + "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xdsconfig" + "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/iotbzh/xds-server/lib/xsapiv1" - - "github.com/iotbzh/xds-server/lib/syncthing" - "github.com/iotbzh/xds-server/lib/xdsconfig" ) const cookieMaxAge = "3600" @@ -49,8 +48,10 @@ type Context struct { SThgInotCmd *exec.Cmd mfolders *Folders sdks *SDKs + targets *Targets WWWServer *WebServer sessions *Sessions + events *Events Exit chan os.Signal } @@ -128,6 +129,9 @@ func (ctx *Context) Run() (int, error) { ctx._logPrint("Logging file for HTTP requests: %s\n", logFileHTTPReq) } + // Create events management + ctx.events = EventsConstructor(ctx) + // Create syncthing instance when section "syncthing" is present in server-config.json if ctx.Config.FileConf.SThgConf != nil { ctx.SThg = st.NewSyncThing(ctx.Config, ctx.Log) @@ -175,7 +179,7 @@ func (ctx *Context) Run() (int, error) { } // Init model folder - ctx.mfolders = FoldersNew(ctx) + ctx.mfolders = FoldersConstructor(ctx) // Load initial folders config from disk if err := ctx.mfolders.LoadConfig(); err != nil { @@ -183,16 +187,24 @@ func (ctx *Context) Run() (int, error) { } // Init cross SDKs - ctx.sdks, err = NewSDKs(ctx) + ctx.sdks, err = SDKsConstructor(ctx) if err != nil { return -6, err } + // Init target and terminals model + ctx.targets = TargetsConstructor(ctx) + + // Load initial target & terminal config + if err := ctx.targets.LoadConfig(); err != nil { + return -6, err + } + // Create Web Server - ctx.WWWServer = NewWebServer(ctx) + ctx.WWWServer = WebServerConstructor(ctx) // Sessions manager - ctx.sessions = NewClientSessions(ctx, cookieMaxAge) + ctx.sessions = ClientSessionsConstructor(ctx, cookieMaxAge) // Run Web Server until exit requested (blocking call) if err = ctx.WWWServer.Serve(); err != nil {