コード例 #1
0
        public static void ShutdownApplication(string physicalDir)
        {
            string             appId = physicalDir.GetHashCode().ToString("x");
            ApplicationManager applicationManager = ApplicationManager.GetApplicationManager();

            applicationManager.ShutdownApplication(appId);
        }
コード例 #2
0
 public ApplicationInfo GetRunningApplication(string physicalPath)
 {
     foreach (ApplicationInfo applicationInfo in ApplicationManager.GetApplicationManager().GetRunningApplications())
     {
         if (applicationInfo.PhysicalPath == physicalPath)
         {
             return(applicationInfo);
         }
     }
     return(null);
 }
コード例 #3
0
        public static object CreateApplicationHost(Type hostType, string virtualDir, string physicalDir, string privateBinPath)
        {
            if (!StringUtil.StringEndsWith(physicalDir, Path.DirectorySeparatorChar))
            {
                physicalDir = physicalDir + Path.DirectorySeparatorChar;
            }

            string             appId = physicalDir.GetHashCode().ToString("x");
            ApplicationManager applicationManager = ApplicationManager.GetApplicationManager();

            return(applicationManager.CreateObject(appId, hostType, virtualDir, physicalDir, true));
        }
コード例 #4
0
        public void StartApplication(string path)
        {
            if (_log != null && _log.IsDebugEnabled)
            {
                _log.Debug(string.Format("Starting application from {0}", path));
            }

            lock (SyncRoot)
            {
                foreach (ApplicationInfo applicationInfo in ApplicationManager.GetApplicationManager().GetRunningApplications())
                {
                    if (applicationInfo.PhysicalPath == path)
                    {
                        throw new InvalidOperationException("Application already started");
                    }
                }
                //if (_hosts.ContainsKey(path))
                //    throw new InvalidOperationException("Application already started");
                string physicalPath = path;
                string virtualPath  = string.Empty;
                try
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(path);
                    string        appName       = directoryInfo.Name;
                    virtualPath = "/" + directoryInfo.Name;
                    if (_log != null)
                    {
                        _log.Debug("Starting application " + appName);
                    }
                    //_log.Debug("PhysicalPath = " + physicalPath);
                    //_log.Debug("VirtualPath = " + virtualPath);
                    string shadowCopyAssemblyList = string.Empty;

                    FluorineRuntimeProxy host = FluorineRuntimeProxy.Start(this, physicalPath, virtualPath, null, null, shadowCopyAssemblyList, _singleDomain);
                    host.Start();
                    //_hosts.Add(physicalPath, host);
                }
                catch (Exception exception)
                {
                    if (_log != null && _log.IsErrorEnabled)
                    {
                        _log.Error("Error starting application " + virtualPath, exception);
                    }
                    if (ApplicationError != null)
                    {
                        ApplicationError(this, new ApplicationErrorEventArgs(new ApplicationInfo(null, VirtualPath.Create(virtualPath), physicalPath), exception));
                    }
                    //throw;
                }
            }
        }
コード例 #5
0
        public void StopApplication(string appId)
        {
            if (_log != null && _log.IsDebugEnabled)
            {
                _log.Debug(string.Format("Stopping application {0}", appId));
            }

            lock (SyncRoot)
            {
                foreach (ApplicationInfo applicationInfo in ApplicationManager.GetApplicationManager().GetRunningApplications())
                {
                    if (applicationInfo.Id == appId)
                    {
                        ApplicationHost.ShutdownApplication(applicationInfo.PhysicalPath);
                    }
                }
            }
        }
コード例 #6
0
        public void Shutdown()
        {
            if (_log != null && _log.IsDebugEnabled)
            {
                _log.Debug("Stopping HostManager.");
            }

            lock (SyncRoot)
            {
                _serverTimer.Enabled = false;
                try
                {
                    AppDomain.CurrentDomain.UnhandledException -= new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                    foreach (ApplicationInfo applicationInfo in ApplicationManager.GetApplicationManager().GetRunningApplications())
                    {
                        IRegisteredObject registeredObject = ApplicationManager.GetApplicationManager().GetObject(applicationInfo.Id, typeof(FluorineRuntimeProxy));
                        if (registeredObject != null)
                        {
                            registeredObject.Stop(true);
                        }
                    }
                    ApplicationManager.GetApplicationManager().ShutdownAll();
                    if (_log != null && _log.IsDebugEnabled)
                    {
                        _log.Debug("Stopped HostManager.");
                    }
                }
                catch (Exception ex)
                {
                    if (_log != null)
                    {
                        _log.Fatal("Failed to stop HostManager.", ex);
                    }
                }
            }
        }
コード例 #7
0
 public ApplicationInfo[] GetRunningApplications()
 {
     return(ApplicationManager.GetApplicationManager().GetRunningApplications());
 }