Exemplo n.º 1
0
        public void Start(CommandLineParameters parameters)
        {
            logger.Info("Starting BottomShelf host.");

            var servicesDirectory = Path.GetFullPath(parameters.ServicesDirectory);
            watcher = new FileSystemWatcher(servicesDirectory, parameters.FileSystemPoll);

            hostedServices = new AssemblyScanner().Scan(servicesDirectory);
            hostedServices.ForEach(hs => StartHostedService(hs, watcher));

            watcher.Start();

            logger.Info("Started monitoring changes in '{0}'.", servicesDirectory);
        }
Exemplo n.º 2
0
        public void Start(FileSystemWatcher watcher, Action removeHostedService)
        {
            var appDomainSetup = new AppDomainSetup { ConfigurationFile = string.Format("{0}.config", assemblyFile), ShadowCopyFiles = "true", ApplicationBase = Path.GetDirectoryName(assemblyFile)};
            appDomain = AppDomain.CreateDomain(string.Format("BottomShelf.Host - {0}", HostedServiceTypeName), new Evidence(), appDomainSetup);

            try
            {
                hostedServiceInstance = (HostedServiceBase)appDomain.CreateInstanceAndUnwrap(assemblyName.FullName, HostedServiceTypeName);
                hostedServiceInstance.Start();
            }
            catch(Exception exception)
            {
                logger.Error(exception);
                removeHostedService();
            }
        }
Exemplo n.º 3
0
 private void StartHostedService(HostedService hostedService, FileSystemWatcher watcher)
 {
     logger.Info("Starting service '{0}'.", hostedService.HostedServiceTypeName);
     hostedService.Start(watcher, () => hostedServices.Remove(hostedService));
     logger.Info("Started service '{0}'.", hostedService.HostedServiceTypeName);
 }