Windows 服务并关闭 EC2 节点

发布于 2024-07-16 00:29:45 字数 872 浏览 6 评论 0原文

我现在在测试台 EC2 节点上运行了一个相当简单的 Windows 服务,基本上:

  • 当服务启动时,调用本地数据中心计算机上的 Web 服务(该服务设置为自动启动,因此它在实例启动时运行)上线)。
  • 每分钟调用另一个 Web 服务一次作为监控心跳。
  • 当服务停止时调用第三个 Web 服务。

我们在 Linux EC2 实例中使用它效果非常好,并且 Windows 服务在启动、检测信号和手动停止时运行良好。

问题是,当通过 ElasticFox、Rightscale 等终止节点时,服务似乎永远不会停止,或者至少,它永远不会进行 Web 服务调用。 有什么想法吗?

[请注意,这是从我在 AWS 开发者论坛上的帖子中逐字复制的,但与 SO 相比,流量超低。 抱歉!]

编辑:关于网络宕机的问题,我也不是最熟悉Windows服务的,如果我将Netman设置为服务依赖项,服务终止的顺序会是这样吗?保证尊重这一点?

关于 EBS,我们为在普通 Linux 实例上运行的类似系统采用的模型将应用程序服务器视为短暂的,因此 EBS 不会给我们带来太大好处。 我们在 EC2 之上使用 Rightscale,这会使 Linux 实例的挂钩关闭,因此我们只是将实例的日志发送到其他地方。

编辑 #2:嗯,我收到 AWS 工作人员的回复比我预期的要快得多:

对于 Windows,由于某些技术限制,通过 API(即通过 elasticfox、rightscale 等)终止是硬关闭。 这意味着这就像使用电源按钮而不是关机来关闭机器。

有趣..

I've got a fairly simple Windows service running on testbed EC2 nodes right now that basically:

  • Calls a Web Service on a machine in our local data center when the service starts (the service is set to Automatic startup, so it runs when the instance comes online).
  • Calls another Web Service once a minute as a monitoring heartbeat.
  • Calls a third Web Service when the service stops.

We're using this in our Linux EC2 instances perfectly fine, and the Windows service works fine on startup, heartbeat, and manual stoppage.

The problem is that when terminating the node via ElasticFox, Rightscale, etc. the service never seems to be stopped, or at least, it never makes the Web Service call. Any thoughts?

[Note that this is copied verbatim from my post on the AWS developer forums, but that is super-low traffic compared to SO. Apologies!]

Edit: Regarding the point about the network going down, I'm also not the most well-versed in Windows services, if I set Netman as a service dependency, would the order of service termination be guaranteed to respect that?

Regarding EBS, the model we've adopted for a similar system running on plain ol' Linux instances treats app servers as ephemeral, so EBS wouldn't benefit us that much. We use Rightscale on top of EC2, which makes hooking into Linux instances shutting down, so we just ship off the instance's logs elsewhere.

Edit #2: Well, I got a reply from the AWS staff much faster than I expected:

For windows, terminating through API (which means through elasticfox ,rightscale etc.) is a hard shutdown due to some technical limitations. It means it is like turning off your machine with power button instead of shutdown.

Interesting..

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

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

发布评论

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

评论(2

明月松间行 2024-07-23 00:29:45

Windows 关闭时会发生很多事情,所以我的猜测是您的 Web 服务调用所需的某些内容已经停止,首先猜测是网络连接。

这有点棘手,因为您无法在 C 或 D 驱动器上保留本地日志文件来检查是否至少尝试过调用,因为一旦实例停止,您将永远无法再次访问它们。 您的实例是否使用可以保存日志文件的 EBS 卷?

A lot of things happen when Windows shutsdown so my guess is something has already stopped that your web service call needs, first guess would be the network connection.

It's a bit of a tricky one since you can't keep a local log file on the C or D drives to check whether the call is at least ebing attempted since you'll never be able toa ccess them again once the instance has stopped. Do you use an EBS volume with your instances that could hold a log file?

网名女生简单气质 2024-07-23 00:29:45

我使用新的 Windows EBS 根卷测试了启动和关闭组策略脚本。 当您停止和启动这些实例时,这两个脚本都会按预期在适当的序列中运行。 因此,另一种方法可能是使用 EBS 根卷运行实例并发出停止命令以确保 Windows 实例执行所有关闭序列。 实例停止后,您应该能够终止该实例并释放与其关联的任何 EBS 卷。

I tested the startup and shutdown group policy scripts with the new Windows EBS root volumes. Both these scripts run as expected during the appropriate sequences when you stop and start these instances. An alternative, therefore, might be to run your instances using EBS root volumes and issue a stop command to ensure the Windows instance executes all shutdown sequences. Once the instance is stopped, you should then be able to terminate the instance and release any EBS volumes that are associated with it.

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