服务器失败时,将EXE文件路由具有备份目标

发布于 2025-02-01 08:22:16 字数 138 浏览 4 评论 0原文

我想知道有什么解决方案可以为服务器提供快捷方式,基本上是一个EXE,更多的是1个目标路径基本上在2台服务器上具有相同的应用程序,以便当一台服务器发生故障时,EXE将转到另一个目标路径和找到与快捷方式指向的完全相同的应用程序。任何解决方案都将不胜感激。 thanx

I was wondering what solution is there to give a shortcut to a server, basically an exe, More that 1 target path to basically have the same application on 2 servers so that when one server fails, that the exe goes to the other target path and find the exact same application exe that the shortcut points to. Any solutions would be highly appreciated. Thanx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

树深时见影 2025-02-08 08:22:16

只能通过快捷方式实现这一目标。
您可以找到一些OpenSource HA(高可用)或聚类解决方案。

It`s impossible to achieve such only by a shortcut.
You can find some opensource HA(high available) or clustering solutions.

静水深流 2025-02-08 08:22:16

答案给了我一个指导方针,说明了我的情况有效的问题,我想出了AC#应用程序从本地C:Drive:drive:

        string Directory1 = @"\\sqlsvr01\Releases\Filename";
        string Directory2 = @"\\sqlsvr02\Releases\filename";

        string server1 = @"\\sqlsvr01\Releases\Filename\setup.exe";
        string server2 = @"\\sqlsvr02\Releases\Filename\setup.exe";


        //look for the file on sqlsvr01 - main publish folder
        if (Directory.Exists(Directory1))
        {
            Process.Start(server1);
            Console.WriteLine("SQLSVR01 reached");
            Console.WriteLine("Executing setup.exe from SQLSVR01");
            Console.ReadLine();

            


        }//if the folders are not found in sqlsvr01 - look for the file on 
          //sqlsvr02 - secondary publish folder
        else if (Directory.Exists(Directory2))
        {
            Process.Start(server2);
            Console.WriteLine("sqlsvr02 reached");
            Console.WriteLine("Executing setup.exe from sqlsvr02");
            Console.ReadLine();

           
        }
        else
        {
            Console.WriteLine("None accessible");
            
        }

The answer gave me a guideline to what worked in my situation and i came up with a c# application ran from the local C: drive:

        string Directory1 = @"\\sqlsvr01\Releases\Filename";
        string Directory2 = @"\\sqlsvr02\Releases\filename";

        string server1 = @"\\sqlsvr01\Releases\Filename\setup.exe";
        string server2 = @"\\sqlsvr02\Releases\Filename\setup.exe";


        //look for the file on sqlsvr01 - main publish folder
        if (Directory.Exists(Directory1))
        {
            Process.Start(server1);
            Console.WriteLine("SQLSVR01 reached");
            Console.WriteLine("Executing setup.exe from SQLSVR01");
            Console.ReadLine();

            


        }//if the folders are not found in sqlsvr01 - look for the file on 
          //sqlsvr02 - secondary publish folder
        else if (Directory.Exists(Directory2))
        {
            Process.Start(server2);
            Console.WriteLine("sqlsvr02 reached");
            Console.WriteLine("Executing setup.exe from sqlsvr02");
            Console.ReadLine();

           
        }
        else
        {
            Console.WriteLine("None accessible");
            
        }
吖咩 2025-02-08 08:22:16

测试是否存在(可访问)在首选的服务器上。如果是,请开始。如果没有,请从备份服务器启动。您必须将脚本路径适应UNC路径或映射驱动器,取决于您使用的内容。未经测试:

set "_path=path_to_exe"
set server1=hostname1
set server2=hostname2

if exist "%server1%\%_path%\file.exe" (
   "%server1%\%_path%\file.exe"
   ) else (
   "%server2%\%_path%\file.exe"
   )

Test if file exist (is reachable) on prefered server. If yes, start it. If no, start it from backup server. You have to adapt script paths to UNC path or mapped drives, depend on what you are using. UNTESTED:

set "_path=path_to_exe"
set server1=hostname1
set server2=hostname2

if exist "%server1%\%_path%\file.exe" (
   "%server1%\%_path%\file.exe"
   ) else (
   "%server2%\%_path%\file.exe"
   )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文