示例#1
0
        private Resin(ResinArgs args)
        {
            ResinArgs = args;

            _resinHome     = ResinArgs.ResinHome;
            _rootDirectory = ResinArgs.ResinRoot;
            _javaHome      = ResinArgs.JavaHome;
        }
示例#2
0
        public static int Main(String[] args)
        {
            ResinArgs resinArgs = new ResinArgs(Environment.GetCommandLineArgs());

            Resin resin = new Resin(resinArgs);

            return(resin.Execute());
        }
示例#3
0
        public static int Main(String[] args)
        {
            ResinArgs resinArgs = new ResinArgs(Environment.GetCommandLineArgs());

              Resin resin = new Resin(resinArgs);

              return resin.Execute();
        }
示例#4
0
        private Resin(ResinArgs args)
        {
            ResinArgs = args;

              _resinHome = ResinArgs.ResinHome;
              _rootDirectory = ResinArgs.ResinRoot;
              _javaHome = ResinArgs.JavaHome;
        }
    private Resin(String[] args)
    {
      ResinArgs = new ResinArgs(args);

      ServiceName = ResinArgs.ServiceName;
      if (ServiceName == null)
        ServiceName = "Resin";

      _displayName = "Resin Web Server";
    }
示例#6
0
        private Resin(ResinArgs args)
        {
            ResinArgs = args;

            _resinHome     = ResinArgs.ResinHome;
            _rootDirectory = ResinArgs.ResinRoot;
            _javaHome      = ResinArgs.JavaHome;

            //_mutex = new Mutex(false, @"Global\com.caucho.Resin." + _rootDirectory);
            //_mutex = new Mutex(false, @"Global\com.caucho.Resin");

            if (_mutex == null)
            {
                _mutex = new Mutex(false, @"Global\com.caucho.Resin." + _rootDirectory);
            }
        }
示例#7
0
        public void FindResinServices()
        {
            RegistryKey services = Registry.LocalMachine.OpenSubKey(Setup.REG_SERVICES);

            if (services == null)
            {
                return;
            }

            foreach (String name in services.GetSubKeyNames())
            {
                RegistryKey key = services.OpenSubKey(name);

                if (key == null)
                {
                    continue;
                }

                try
                {
                    Object imagePathObj = key.GetValue("ImagePath");

                    if (imagePathObj == null || "".Equals(imagePathObj))
                    {
                        continue;
                    }

                    String imagePath = (String)imagePathObj;

                    String lowerCaseImagePath = imagePath.ToLower();

                    if ((imagePath.IndexOf("resin.exe") > 0 ||
                         imagePath.IndexOf("httpd.exe") > 0) &&
                        imagePath.IndexOf("-service") > 0)
                    {
                        ResinArgs resinArgs = new ResinArgs(imagePath);

                        ResinService resin = null;
                        if (resinArgs.ResinHome != null)
                        {
                            resin      = new ResinService();
                            resin.Home = resinArgs.ResinHome;
                        }
                        else if (resinArgs.Exe != null)
                        {
                            String exe  = resinArgs.Exe;
                            String home = exe.Substring(0, exe.Length - 10);
                            if (Util.IsResinHome(home))
                            {
                                resin      = new ResinService();
                                resin.Home = home;
                            }
                        }

                        if (resin == null)
                        {
                            continue;
                        }

                        resin.Exe = resinArgs.Exe;

                        resin.Name                 = name;
                        resin.Server               = resinArgs.Server;
                        resin.DynamicServer        = resinArgs.DynamicServer;
                        resin.ElasticServer        = resinArgs.ElasticServer;
                        resin.Cluster              = resinArgs.Cluster;
                        resin.Root                 = resinArgs.ResinRoot;
                        resin.Conf                 = resinArgs.Conf;
                        resin.Log                  = resinArgs.Log;
                        resin.User                 = "******";
                        resin.JavaHome             = resinArgs.JavaHome;
                        resin.ElasticServerAddress = resinArgs.ElasticServerAddress;
                        resin.ElasticServerPort    = resinArgs.ElasticServerPort;

                        if (resinArgs.JmxPort != null && !"".Equals(resinArgs.JmxPort))
                        {
                            resin.JmxPort = int.Parse(resinArgs.JmxPort);
                        }

                        if (resinArgs.DebugPort != null && !"".Equals(resinArgs.DebugPort))
                        {
                            resin.DebugPort = int.Parse(resinArgs.DebugPort);
                        }

                        if (resinArgs.WatchDogPort != null && !"".Equals(resinArgs.WatchDogPort))
                        {
                            resin.WatchdogPort = int.Parse(resinArgs.WatchDogPort);
                        }

                        resin.IsPreview = resinArgs.IsPreview;

                        resin.ExtraParams = resinArgs.ResinArguments;

                        AddResinService(resin);
                    }
                }
                catch (Exception e)
                {
                    LogStartupError(e.Message, e);
                }
                finally
                {
                    key.Close();
                }
            }

            services.Close();
        }
示例#8
0
        public void FindResin()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                if (DriveType.Fixed != drive.DriveType && DriveType.Ram != drive.DriveType)
                {
                    continue;
                }
                DirectoryInfo   root        = drive.RootDirectory;
                DirectoryInfo[] directories = root.GetDirectories();
                foreach (DirectoryInfo directory in directories)
                {
                    if (directory.Name.StartsWith("resin", StringComparison.CurrentCultureIgnoreCase) &&
                        Util.IsResinHome(directory.FullName))
                    {
                        Resin resin = new Resin(Util.Canonicalize(directory.FullName));
                        if (!HasResin(resin))
                        {
                            AddResin(resin);
                        }
                    }
                    else if (directory.Name.Contains("appservers"))
                    {
                        DirectoryInfo[] appserverDirectories = directory.GetDirectories();
                        foreach (DirectoryInfo appserverDir in appserverDirectories)
                        {
                            if (Util.IsResinHome(appserverDir.FullName))
                            {
                                String home  = Util.Canonicalize(appserverDir.FullName);
                                Resin  resin = new Resin(home);
                                if (!HasResin(resin))
                                {
                                    AddResin(resin);
                                }
                            }
                        }
                    }
                }
            }

            String currentResin    = Util.GetCurrentResinFromRegistry();
            Resin  resinInRegistry = null;

            if (currentResin != null)
            {
                currentResin    = Util.Canonicalize(currentResin);
                resinInRegistry = new Resin(currentResin);

                if (!HasResin(resinInRegistry))
                {
                    AddResin(resinInRegistry);
                }
            }

            RegistryKey services = Registry.LocalMachine.OpenSubKey(Setup.REG_SERVICES);

            foreach (String name in services.GetSubKeyNames())
            {
                RegistryKey key = services.OpenSubKey(name);
                try
                {
                    Object imagePathObj = key.GetValue("ImagePath");
                    if (imagePathObj == null && !"".Equals(imagePathObj))
                    {
                        continue;
                    }

                    String imagePath          = (String)imagePathObj;
                    String lowerCaseImagePath = imagePath.ToLower();

                    if (imagePath.IndexOf("resin.exe") != -1)
                    {
                        ResinArgs resinArgs = new ResinArgs(imagePath);
                        Resin     resin     = null;
                        if (resinArgs.ResinHome != null)
                        {
                            resin = new Resin(resinArgs.ResinHome);
                        }
                        else if (resinArgs.Exe != null)
                        {
                            String exe  = resinArgs.Exe;
                            String home = exe.Substring(0, exe.Length - 10);
                            if (Util.IsResinHome(home))
                            {
                                resin = new Resin(home);
                            }
                        }

                        if (resin != null && !HasResin(resin))
                        {
                            AddResin(resin);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogStartupError(e.Message, e);
                }
                finally
                {
                    key.Close();
                }
            }

            services.Close();

            String resinHome = Util.GetResinHome(null, System.Reflection.Assembly.GetExecutingAssembly().Location);

            foreach (Resin resin in _resinList)
            {
                if (resin.Home.Equals(resinHome))
                {
                    Resin = resin;

                    return;
                }
            }

            if (Resin == null && resinInRegistry != null)
            {
                Resin = resinInRegistry;
            }

            if (Resin == null && resinHome != null)
            {
                Resin = new Resin(resinHome);

                AddResin(Resin);
            }

            if (Resin == null && _resinList.Count > 0)
            {
                Resin = _resinList[_resinList.Count - 1];
            }
        }