Example #1
0
        private ApplicationInstance StartWebServer(Application application, Tenant tenant, int port)
        {
            try {
                string xsp = Settings.WindowsXSPWebServerPath;
                if (MonoscapeUtil.IsRunningOnMono () && (Environment.OSVersion.Platform == PlatformID.Unix))
                    xsp = Settings.UnixXSPWebServerPath;

                string arguments = "--port " + port + " --applications /" + tenant.Name.Replace (" ", "").ToLower () + "/" + MonoscapeUtil.PrepareApplicationVirtualFolderName (application.Name) + ":.";
                string workingDirectory = PrepareApplicationDeployPath (application, tenant.Name, port);
                var p = new Process ()
                {
                    StartInfo = new ProcessStartInfo(xsp, arguments)
                    {
                        RedirectStandardOutput = false,
                        RedirectStandardError = false,
                        UseShellExecute = false,
                        CreateNoWindow = true,
                        WorkingDirectory = workingDirectory
                    }
                };
                if (p.Start ()) {
                    Database.LastWebServerPort = port;
                    ApplicationInstance instance = new ApplicationInstance ();
                    instance.Id = FindNextInstanceId (application);
                    instance.ProcessId = p.Id;
                    instance.ApplicationId = application.Id;
                    instance.ApplicationName = application.Name;
                    instance.NodeId = Database.Node.Id;
                    instance.IpAddress = Database.Node.IpAddress;
                    instance.Port = port;
                    instance.Tenant = tenant;
                    instance.CreatedTime = DateTime.Now;
                    instance.State = "Started";
                    instance.Url = "http://" + instance.IpAddress + ":" + instance.Port + "/" + tenant.Name.Replace (" ", "").ToLower () + "/" + MonoscapeUtil.PrepareApplicationVirtualFolderName (application.Name);

                    Database.ChildProcesses.Add (p);
                    Log.Info (typeof(NcApplicationGridService), "Started web server: " + instance.Url);
                    return instance;
                }
                else {
                    Database.ChildProcesses.Add (p);
                    Log.Error (typeof(NcApplicationGridService), "Could not start web server for application " + application.Name + " " + application.Version);
                    return null;
                }
            }
            catch (Exception e) {
                Log.Error (this, "Could not start web server");
                throw e;
            }
        }
Example #2
0
 public ApplicationInstance Clone()
 {
     ApplicationInstance clone = new ApplicationInstance();
     clone.Id = Id;
     clone.ApplicationId = ApplicationId;
     clone.ApplicationName = ApplicationName;
     clone.NodeId = NodeId;
     clone.ProcessId = ProcessId;
     clone.IpAddress = IpAddress;
     clone.Port = Port;
     clone.Url = Url;
     clone.Tenant = Tenant;
     clone.RowState = RowState;
     clone.RowVersion = RowVersion;
     clone.CreatedTime = CreatedTime;
     clone.State = State;
     clone.RequestCount = RequestCount;
     return clone;
 }
Example #3
0
 public bool Equals(ApplicationInstance instance)
 {
     return ((NodeId == instance.NodeId) && (ApplicationId == instance.ApplicationId) && (Id == instance.Id));
 }
 private void RemoveApplicationInstance_(ApplicationInstance instance_)
 {
     ApplicationInstance clone = instance_.Clone();
     Database.GetInstance().RoutingMesh.Remove(instance_);
     clone.CreatedTime = DateTime.Now;
     clone.State = "Stopped";
     Database.GetInstance().RoutingMeshHistory.Add(clone);
 }