/// <remarks>Never run a cell process entry point more than once per AppDomain.</remarks>
        public void Run(CellDefinition cellDefinition, IDeploymentReader deploymentReader, ApplicationEnvironment environment)
        {
            // Load Assemblies into AppDomain
            var assemblies = deploymentReader.GetAssembliesAndSymbols(cellDefinition.Assemblies).ToList();
            var loader = new AssemblyLoader();
            loader.LoadAssembliesIntoAppDomain(assemblies, environment);

            // Create the EntryPoint
            var entryPointTypeName = cellDefinition.EntryPointTypeName;
            if (string.IsNullOrEmpty(entryPointTypeName))
            {
                entryPointTypeName = "Lokad.Cloud.Services.AppEntryPoint.EntryPoint, Lokad.Cloud.Services.AppEntryPoint";
            }

            var entryPointType = Type.GetType(entryPointTypeName);
            if (entryPointType == null)
            {
                throw new InvalidOperationException("Type " + entryPointTypeName + " not found.");
            }

            _appEntryPoint = (IApplicationEntryPoint)Activator.CreateInstance(entryPointType);

            var settings = string.IsNullOrEmpty(cellDefinition.SettingsXml) ? new XElement("Settings") : XElement.Parse(cellDefinition.SettingsXml);

            // Run
            _appEntryPoint.Run(settings, deploymentReader, environment, _externalCancellationTokenSource.Token);
        }
        public HostContext(IHostObserver hostObserver, IDeploymentReader deploymentReader)
        {
            Observer = hostObserver;
            DeploymentReader = deploymentReader;

            _identity = new HostLifeIdentity(Environment.MachineName, Guid.NewGuid().ToString("N"));
        }
Beispiel #3
0
        /// <remarks>Never run a cell process entry point more than once per AppDomain.</remarks>
        public void Run(CellDefinition cellDefinition, IDeploymentReader deploymentReader, ApplicationEnvironment environment)
        {
            // Load Assemblies into AppDomain
            var assemblies = deploymentReader.GetAssembliesAndSymbols(cellDefinition.Assemblies).ToList();
            var loader     = new AssemblyLoader();

            loader.LoadAssembliesIntoAppDomain(assemblies, environment);

            // Create the EntryPoint
            var entryPointTypeName = cellDefinition.EntryPointTypeName;

            if (string.IsNullOrEmpty(entryPointTypeName))
            {
                entryPointTypeName = "Lokad.Cloud.Services.AppEntryPoint.EntryPoint, Lokad.Cloud.Services.AppEntryPoint";
            }

            var entryPointType = Type.GetType(entryPointTypeName);

            if (entryPointType == null)
            {
                throw new InvalidOperationException("Type " + entryPointTypeName + " not found.");
            }

            _appEntryPoint = (IApplicationEntryPoint)Activator.CreateInstance(entryPointType);

            var settings = string.IsNullOrEmpty(cellDefinition.SettingsXml) ? new XElement("Settings") : XElement.Parse(cellDefinition.SettingsXml);

            // Run
            _appEntryPoint.Run(settings, deploymentReader, environment, _externalCancellationTokenSource.Token);
        }
        public HostContext(IDeploymentReader deploymentReader, IHostObserver observer)
        {
            Observer = observer;
            DeploymentReader = deploymentReader;

            // TODO: Replace GUID with global blob counter
            _identity = new HostLifeIdentity(Environment.MachineName, Guid.NewGuid().ToString("N"));
        }
Beispiel #5
0
        public void Run(XElement settings, IDeploymentReader deploymentReader, IApplicationEnvironment environment, CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                _logger.Write("Timestamp: {0} [App1]", DateTime.Now);

                cancellationToken.WaitHandle.WaitOne(5000);
            }
        }
Beispiel #6
0
        public void Run(XElement settings, IDeploymentReader deploymentReader, IApplicationEnvironment environment, CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                _logger.Write("[App1] {0} {1}: Timestamp {2}", environment.CurrentDeploymentName, environment.CellName, DateTime.Now);

                cancellationToken.WaitHandle.WaitOne(5000);
            }
        }
 void IApplicationEntryPoint.Run(XElement settings, IDeploymentReader deploymentReader, IApplicationEnvironment environment, CancellationToken cancellationToken)
 {
     var log = File.AppendText("app2_log.txt");
     Run(cancellationToken, logtext =>
         {
             log.WriteLine("[App1] {0}-{1} on {2}: {3}", environment.Cell.SolutionName, environment.Cell.CellName, environment.Host.WorkerName, logtext);
             log.Flush();
         });
 }
        public void Run(XElement settings, IDeploymentReader deploymentReader, IApplicationEnvironment environment, CancellationToken cancellationToken)
        {
            _log.WriteLine("[App1] {0}-{1} on {2}: Started {3}", environment.Cell.SolutionName, environment.Cell.CellName, environment.Host.WorkerName, DateTime.Now);
            _log.Flush();

            while (!cancellationToken.IsCancellationRequested)
            {
                _log.WriteLine("[App1] {0}-{1} on {2}: Timestamp {3}", environment.Cell.SolutionName, environment.Cell.CellName, environment.Host.WorkerName, DateTime.Now);
                _log.Flush();

                cancellationToken.WaitHandle.WaitOne(5000);
            }

            _log.WriteLine("[App1] {0}-{1} on {2}: Stopped {3}", environment.Cell.SolutionName, environment.Cell.CellName, environment.Host.WorkerName, DateTime.Now);
            _log.Flush();
        }
Beispiel #9
0
 public HostContext(IHostObserver hostObserver, IDeploymentReader deploymentReader)
 {
     Observer = hostObserver;
     DeploymentReader = deploymentReader;
 }