コード例 #1
0
ファイル: Master.cs プロジェクト: pjanec/dirigent
        private ConcurrentQueue <SynchronousOp> _synchronousOps;        // operations waiting to be processed within master's tick


        #endregion

        public Master(AppConfig ac, string rootForRelativePaths)
        {
            log.Info($"Running Master at IP {ac.LocalIP}, port {ac.MasterPort}, cliPort {ac.CliPort}");

            _localIpAddr = ac.LocalIP;
            _port        = ac.MasterPort;

            _rootForRelativePaths = rootForRelativePaths;

            _allAppStates    = new AllAppsStateRegistry();
            _allClientStates = new AllClientStateRegistry();

            _allAppDefs          = new AllAppsDefRegistry();
            _allAppDefs.Added   += SendAppDefAddedOrUpdated;
            _allAppDefs.Updated += SendAppDefAddedOrUpdated;

            _defaultAppDefs = new Dictionary <AppIdTuple, AppDef>();

            _plans = new PlanRegistry(this);
            _plans.PlanDefUpdated += SendPlanDefUpdated;

            _scripts = new ScriptRegistry(this);

            _server          = new Server(ac.MasterPort);
            _swClientRefresh = new Stopwatch();
            _swClientRefresh.Restart();

            // start a telnet client server
            _cliProc = new CLIProcessor(this);

            log.InfoFormat("Command Line Interface running on port {0}", ac.CliPort);
            _telnetServer = new TelnetServer("0.0.0.0", ac.CliPort, _cliProc);

            var sharedConfig = LoadSharedConfig(ac.SharedCfgFileName);

            InitFromConfig(sharedConfig);

            _tickers = new TickableCollection();

            _synchronousOps = new ConcurrentQueue <SynchronousOp>();

            _webServerCTS  = new CancellationTokenSource();
            _webServerTask = Web.WebServerRunner.RunWebServerAsync(this, "http://*:8877", Web.WebServerRunner.HtmlRootPath, _webServerCTS.Token);

            //// FIXME: Just for testing the script! To be removed!
            //var script = new DemoScript1();
            //Script.InitScriptInstance( script, "Demo1", this );
            //_tickers.Install( script );
            //RunScript("DemoScript1", "Scripts/DemoScript1.cs");
            //RunScript("DemoScript1");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: pjanec/dirigent
        static void Initialize()
        {
            try
            {
                var ac = getAppConfig();

                log.InfoFormat("Master running on port {0}", ac.masterPort);

                IEnumerable<ILaunchPlan> planRepo = (ac.scfg != null) ? ac.scfg.Plans : null;

                var s = new Server(ac.masterPort, planRepo, ac.startupPlanName);
                // server works through its ServerRemoteObject

            }
            catch (Exception ex)
            {
                log.Error(ex);
                //ExceptionDialog.showException(ex, "Dirigent Exception", "");
            }
        }