如何验证外部资源是否可用

发布于 2024-07-27 15:31:01 字数 337 浏览 16 评论 0原文

如何在不大幅增加系统范围的情况下验证系统环境的状态?

我正在开发一个与一些远程服务器通信的系统。 例如,它连接到服务器并获取在该服务器上运行的 MyApp 的日志。 这些远程服务器使用多种操作系统并进行“手动”管理。 我们的系统无法在远程服务器上安装MyApp,但是如果没有安装MyApp,我们的系统就无法正常运行。

我想在我们的软件完成工作之前检查这些应用程序是否已安装在远程服务器上。 我希望这些检查能够抛出合理的错误消息。

我担心的是,如果我们的系统不“接管”这些远程服务器并负责它们的配置,就无法有效地完成这一任务——这超出了我们项目的范围。

你怎么认为?

How do you verify the state of the environment for a system without drastically increasing the scope of the system?

I'm working on a system which talks to some remote servers. For example, it connects to a server and grabs logs of MyApp that ran on that server. These remote servers use a multitude of operating systems and are "manually" managed. Our system can't install MyApp on the remote servers, but our system can't function correctly if MyApp isn't installed.

I would like to check that these applications are installed on the remote server before our software does its job. And I'd like these checks to throw reasonable error messages.

My fear is that this can't be effectively done without our system "taking over" these remote servers and being responsible for their configuration -- which is way out of scope for our project.

What do you think?

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

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

发布评论

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

评论(2

梦行七里 2024-08-03 15:31:02

我在这里最好的答案是不要检查,而只是尽力尽其所能地完成工作。 如果出现问题,请抛出相应的错误消息。 除了警告用户应用程序未安装之外,预先检查应用程序是否未安装还有什么目的? 这与简单地继续尝试执行然后失败并告诉用户完全相同的消息是一样的。

这确实是一个不错的策略,例如在 Python 中,它鼓励简单地尝试执行该函数,然后在发生错误时正确恢复。

如果您确实想检查外部资源,您可以在服务器上设置消息传递服务,告诉您的应用程序资源是否存在。 我不知道你是否可以这样设置。

My best answer here is not to check and simply try to do the job as best as it can. If and when a problem occurs, throw the appropriate error message. What would be the purpose of checking beforehand that the application is not installed, other than to warn the user that it is not? It would be the same as simply going ahead and attempting to execute and then failing and telling the user the exact same message.

It's really not that bad of a strategy, for example in Python its encouraged to simply try to perform the function and then when an error occurs, recover properly.

If you really want to check for external resources, you could have a messaging service set up on the server which tells your application whether or not the resources exist. I don't know if you're allowed to set that up or not.

面犯桃花 2024-08-03 15:31:02

您可以尝试请求 Web 服务器公开(当然受密码保护)日志目录; 如果您的“MyApp”在安装时创建日志,您只需检查 Web 服务器是否存在安装日志即可。

You might try requesting that a web server expose (password protected, of course) the logs directory; if your "MyApp" creates a log upon installation, you could just check the web server for the presence of the installation log.

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