示例#1
0
        public static void StartChildren(FileInfo[] configFiles, ConfigurationManager configurationManager)
        {
            if (configFiles == null)
                throw new ArgumentNullException ("configFiles");
            if (configurationManager == null)
                throw new ArgumentNullException ("configurationManager");
            foreach (var fileInfo in configFiles) {
                Logger.Write(LogLevel.Debug, "Loading {0}", fileInfo.Name);
                var childConfigurationManager = new ChildConfigurationManager();
                string fullName = fileInfo.FullName;
                childConfigurationManager.LoadXmlConfig(fullName);
                string user = childConfigurationManager.User;
                string fastCgiCommand = configurationManager.FastCgiCommand;

                ChildInfo child;
                if (Platform.IsUnix) {
                    if (String.IsNullOrEmpty(user)) {
                        Logger.Write(LogLevel.Warning, "Configuration file {0} didn't specify username, defaulting to file owner", fileInfo.Name);
                        user = UnixFileSystemInfo.GetFileSystemEntry(fullName).OwnerUser.UserName;
                    }

                    child = Spawner.RunAs(user, Spawner.SpawnChild, fullName, fastCgiCommand);
                } else {
                    Logger.Write(LogLevel.Warning, "Configuration file {0} didn't specify username, defaulting to the current one", fileInfo.Name);
                    child = Spawner.SpawnChild(fullName, fastCgiCommand);
                }
                children.Add(child);
            }
        }