gpt4 book ai didi

linux - 在谷歌可抢占实例上被抢占时如何保存状态?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:14:06 24 4
gpt4 key购买 nike

我需要能够在基于 Centos 的 Google Compute 实例首次收到抢占信号时保存它的状态。 documentation非常清楚地表明“ACPI G2 Soft Off”信号在抢先关闭前 30 秒发送。不幸的是,Google 没有给出示例来演示如何捕获此信号,我还没有找到捕获它的方法。

我最初的尝试都集中在使用 acpid 守护程序的 ACPI 接口(interface)上。使用它,我已经能够毫无问题地捕获关机(按钮/电源)事件。但无论我 try catch 什么事件(按钮、电源、 sleep ),我都无法捕获到 G2 状态的状态转换,我认为这就是我要寻找的。

有没有人成功地在 Centos(或任何 Linux)环境中捕获抢占信号?

最佳答案

您可能想使用 shutdown scripts为此:

Create and run shutdown scripts that allow you to execute commands right before an instance is terminated or restarted, on a best-effort basis. This is useful if you rely on automated scripts to start up and shut down instances, allowing your instances time to clean up or perform tasks, such as exporting logs, or syncing with other systems.

If you have a managed instance group that is being autoscaled, shutdown scripts can be useful because if an instance is shut down due to autoscaling, the shutdown script performs any actions you define before the instance is terminated. For example, your shutdown script might copy processed data or back up any logs.

Shutdown scripts function very similarly to startup scripts; much of the documentation for startup scripts also applies for shutdown scripts.

但是,由于您完成这项工作的时间有限,请考虑使用持久的外部存储系统,当您的实例被抢占时不会被删除,例如 Google Cloud Storage , Google Cloud Bigtable , Google Cloud Datastore , 或其他。

关于linux - 在谷歌可抢占实例上被抢占时如何保存状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32949150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com