Example #1
0
        /// <summary>
        /// OnStart(): Put startup code here
        ///  - Start threads, get inital data, etc.
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            LOGGER.Info("Starting ProActive Agent service");

            // The location will be read from the registry
            string agentInstallLocation;
            // The location of the cofig file
            string agentConfigLocation;

            // Try to read install and config locations from registry
            RegistryKey confKey = Registry.LocalMachine.OpenSubKey(Constants.REG_SUBKEY);

            if (confKey == null)
            {
                if (LOGGER.IsWarnEnabled)
                {
                    LOGGER.Warn("ProActive Agent could not read " + Constants.REG_SUBKEY + " from windows registry");
                }
                // If registry key is unknown set default locations
                agentInstallLocation = Constants.DEFAULT_INSTALL_LOCATION;
                agentConfigLocation  = Constants.DEFAULT_CONFIG_LOCATION;
            }
            else
            {
                agentInstallLocation = (string)confKey.GetValue(Constants.INSTALL_LOCATION_REG_VALUE_NAME);
                agentConfigLocation  = (string)confKey.GetValue(Constants.CONFIG_LOCATION_REG_VALUE_NAME);
                confKey.Close();
            }

            // Parse the configuration file once per start
            AgentType configuration = null;

            try
            {
                configuration = Utils.readConfig(agentConfigLocation, agentInstallLocation);
            }
            catch (Exception ex)
            {
                LOGGER.Error("An exception occured when reading the configuration file", ex);
                base.Stop();
                return;
            }
            configuration.agentInstallLocation = agentInstallLocation;

            // Read classpath, we cannot start the service if the class path is not set
            try
            {
                Utils.readClasspath(configuration);
            }
            catch (Exception ex)
            {
                LOGGER.Error("An exception occured when reading the classpath", ex);
                base.Stop();
                return;
            }

            this.executorsManager = new ExecutorsManager(configuration);
            this.pipeServerWorker = new Worker(this.executorsManager);
            base.OnStart(args);
        }
Example #2
0
 public Worker(ExecutorsManager manager)
 {
     this.manager        = manager;
     thread              = new Thread(sendExecutorsCount);
     thread.Name         = "GuiCommunicatingWorker";
     thread.IsBackground = true;
     // Start the server pipe
     thread.Start();
 }