コード例 #1
0
        static int consoleAppMain()
        {
            try
            {
                var ac = getAppConfig();

                if (ac.logFileName != "")
                {
                    SetLogFileName(Path.GetFullPath(ac.logFileName));
                }

                //var planRepo = getPlanRepo(ac);

                log.InfoFormat("Running with masterIp={0}, masterPort={1}", ac.masterIP, ac.masterPort);

                // use unique client id to avoid conflict with any other possible client
                string machineId = Guid.NewGuid().ToString();
                var    client    = new Dirigent.Net.Client(machineId, ac.masterIP, ac.masterPort);

                // first connect
                client.Connect();

                // use network-only agent (never local)
                string rootForRelativePaths = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(ac.sharedCfgFileName));
                var    agent = new Dirigent.Agent.Core.Agent(machineId, client, false, rootForRelativePaths);

                // let the agent receive the plan repository from master
                agent.tick();

                // process the console command
                MyCommandRepo cmdRepo = new MyCommandRepo(agent.Control);
                cmdRepo.ParseAndExecute(ac.nonOptionArgs);

                return(0); // everything OK
            }
            catch (Exception ex)
            {
                log.Error(ex);
                //Console.WriteLine(string.Format("Error: {0} [{1}]", ex.Message, ex.GetType().ToString()));
                Console.WriteLine(string.Format("Error: {0}", ex.Message));
                //ExceptionDialog.showException(ex, "Dirigent Exception", "");
                return(-1);
            }
        }
コード例 #2
0
        static bool Initialize()
        {
            try
            {
                var ac = getAppConfig();

                if (AppInstanceAlreadyRunning(ac.masterPort))
                {
                    throw new Exception("Another instance of Dirigent Master is already running!");
                }

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

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

                // start a local network-only agent
                // use unique client id to avoid conflict with any other possible client
                string machineId            = Guid.NewGuid().ToString();
                var    dirigClient          = new Dirigent.Net.Client(machineId, "127.0.0.1", ac.masterPort);
                string rootForRelativePaths = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(ac.sharedCfgFileName));
                agent = new Dirigent.Agent.Core.Agent(machineId, dirigClient, false, rootForRelativePaths);

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


                dirigClient.Connect(); // connect should succeed immediately (server runs locally)

                // start a telnet client server
                log.InfoFormat("Command Line Interface running on port {0}", ac.CLIPort);
                cliServer = new CLIServer("0.0.0.0", ac.CLIPort, agent.Control);
                cliServer.Start();

                return(true);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                //ExceptionDialog.showException(ex, "Dirigent Exception", "");
                return(false);
            }
        }
コード例 #3
0
ファイル: Launcher.cs プロジェクト: pjanec/dirigent
        public Launcher(AppDef appDef, SharedContext sharedContext, Dictionary <string, string>?extraVars = null)
        {
            this.ctrl = sharedContext.Client;
            if (ctrl == null)
            {
                throw new ArgumentNullException("ctrl", "Valid network-bound Dirigent Control required");
            }
            this._appDef   = appDef;
            _sharedContext = sharedContext;

            _relativePathsRoot = sharedContext.RootForRelativePaths;

            this._planName = appDef.PlanName;
            this._masterIP = _sharedContext.Client.MasterIP;

            _extraVars         = extraVars ?? new();
            this._internalVars = BuildVars(appDef, _sharedContext.InternalVars, _extraVars);

            //_cmdRepo = new CommandRepository( ctrl );
            //DirigentCommandRegistrator.Register( _cmdRepo );

            _softKiller = new SoftKiller(appDef);

            // handle the KillSoftly flag for backward compatibility
            if (appDef.KillSoftly)
            {
                if (_softKiller.IsDefined)
                {
                    log.ErrorFormat("{0}: KillSoftly can't be used together with SoftKill! Using just the SoftKill...", appDef.Id);
                }
                else                 // add a single Close action to the soft kill seq, with default timeout
                {
                    _softKiller.AddClose();
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: pjanec/dirigent
        static int consoleAppMain()
        {
            try
            {
                var ac = getAppConfig();

                if (ac.logFileName != "")
                {
                    SetLogFileName(Path.GetFullPath(ac.logFileName));
                }

                //var planRepo = getPlanRepo(ac);

                log.InfoFormat("Running with masterIp={0}, masterPort={1}", ac.masterIP, ac.masterPort);

                // use unique client id to avoid conflict with any other possible client
                string machineId = Guid.NewGuid().ToString();
                var client = new Dirigent.Net.Client(machineId, ac.masterIP, ac.masterPort);

                // first connect
                client.Connect();

                // use network-only agent (never local)
                var agent = new Dirigent.Agent.Core.Agent(machineId, client, false);

                // let the agent receive the plan repository from master
                agent.tick();

                // process the console command
                MyCommandRepo cmdRepo = new MyCommandRepo(agent.Control);
                cmdRepo.ParseAndExecute(ac.nonOptionArgs);

                return 0; // everything OK

            }
            catch (Exception ex)
            {
                log.Error(ex);
                //Console.WriteLine(string.Format("Error: {0} [{1}]", ex.Message, ex.GetType().ToString()));
                Console.WriteLine(string.Format("Error: {0}", ex.Message));
                //ExceptionDialog.showException(ex, "Dirigent Exception", "");
                return -1;
            }
        }