コード例 #1
0
 protected void StopEnvironment()
 {
     try
     {
         _context.RaiseEvent(this, new RFServiceEvent {
             ServiceName = RFSchedulerService.SERVICE_NAME, ServiceCommand = "stop", ServiceParams = null
         });
         _environment.Stop();
     }
     catch (Exception ex)
     {
         RFStatic.Log.Exception(this, "Error stopping service", ex);
     }
 }
コード例 #2
0
        public void StartEnvironment()
        {
            try
            {
                Console.WriteLine("Welcome to RIFF {0}", RFCore.sVersion);

                // currently only a single engine is supported
                var engine       = RIFFSection.GetDefaultEngine();
                var engineConfig = engine.BuildEngineConfiguration();

                try
                {
                    rfEventLog.WriteEntry(String.Format("Starting engine {0} in environment {1} from {2} (RFCore {3})", engine.EngineName, engine.Environment, engine.Assembly, RFCore.sVersion), EventLogEntryType.Information);
                }
                catch (SecurityException)
                {
                    RFStatic.Log.Error(this, "EventLog source has not been created. Please run \"RIFF.Service.exe /install\" as Administrator to create.");
                    return;
                }

                if (_args != null && _args.Length > 0)
                {
                    _environment = RFEnvironments.StartConsole(engine.Environment, engineConfig, engine.Database, new string[] { engine.Assembly });
                    _context     = _environment.Start();

                    if (_args[0] == "command")
                    {
                        // run console command
                        var engineConsole = engineConfig.Console;
                        if (engineConsole != null)
                        {
                            engineConsole.Initialize(_context, engineConfig, engine.Database);
                        }
                        var executor = new RFConsoleExecutor(engineConfig, _context, engine, engineConsole);
                        executor.ExecuteCommand(String.Join(" ", _args.Skip(1)));
                    }
                    else
                    {
                        // run named service
                        var param        = String.Join(" ", _args);
                        var tokens       = new Interfaces.Formats.CSV.CSVParser(param, ' ').Where(t => !string.IsNullOrWhiteSpace(t)).ToArray();
                        var serviceName  = tokens[0];
                        var serviceParam = tokens.Length > 1 ? tokens[1] : null;
                        RFStatic.Log.Info(this, $"Starting service: {serviceName}" + (serviceParam != null ? $"with param: {serviceParam}" : string.Empty));

                        _context.RaiseEvent(this, new RFServiceEvent {
                            ServiceName = serviceName, ServiceCommand = "start", ServiceParams = serviceParam
                        });
                    }
                }
                else
                {
                    if (RFSettings.GetAppSetting("UseMSMQ", true))
                    {
                        CleanUpMSMQ(Environment.MachineName, engine.Environment);
                    }

                    // WCF service
                    _environment = RFEnvironments.StartLocal(engine.Environment, engineConfig, engine.Database, new string[] { engine.Assembly });
                    _context     = _environment.Start();

                    _context.RaiseEvent(this, new RFServiceEvent {
                        ServiceName = RFSchedulerService.SERVICE_NAME, ServiceCommand = "start", ServiceParams = null
                    });

                    var wcfService = new RFService(_context, engineConfig, engine.Database);
                    var uriSetting = RFSettings.GetAppSetting("RFServiceUri");
                    if (uriSetting.NotBlank())
                    {
                        _serviceHost = new ServiceHost(wcfService, new Uri(uriSetting));
                    }
                    else
                    {
                        _serviceHost = new ServiceHost(wcfService);
                    }
                    _serviceHost.Open();
                }
            }
            catch (Exception ex)
            {
                rfEventLog.WriteEntry("OnStart Error: " + ex.Message, EventLogEntryType.Error);
                RFStatic.Log.Exception(this, ex, "Error initializing RFService.");
                throw;
            }
        }
コード例 #3
0
ファイル: RFService.cs プロジェクト: awesomedotnetcore/riff
 public void ServiceCommand(string serviceName, string command, string param)
 {
     _context.RaiseEvent(this, new RFServiceEvent {
         ServiceName = serviceName, ServiceCommand = command, ServiceParams = param, Timestamp = DateTime.Now
     });
 }