예제 #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
파일: 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;
            }
        }