gpt4 book ai didi

google-compute-engine - 启动脚本在停止之前是否有时间限制?

转载 作者:行者123 更新时间:2023-12-04 03:21:15 25 4
gpt4 key购买 nike

我需要在谷歌计算引擎中创建一个 VM 实例,启动脚本需要 30 分钟,但它永远不会完成,它会在实例启动后大约 10 分钟停止。有超时吗?是否有另一种选择来完成我需要做的事情?谢谢!

最佳答案

鉴于评论中的额外说明:

My script downloads another script and then executes it, and what that script does is download some big files, and then compute some values based on latitude/longitude. Then, when the process is finished, the VM is destroyed.

我的建议是异步而不是同步运行大型下载和处理。原因是如果它是同步的,它是 VM 启动的一部分(在关键路径中),并且 VM 监控基础设施注意到 VM 没有在合理的时间内完成其启动阶段并终止它。

相反,将繁重的处理从关键路径中移出并在后台执行,即异步执行。

换句话说,启动脚本目前可能是这样的:

# Download the external script
curl [...] -o /tmp/script.sh

# Run the file download, computation, etc. and shut down the VM.
/tmp/script.sh

我建议将其转换为:

# Download the external script
curl [...] -o /tmp/script.sh

# Run the file download, computation, etc. and shut down the VM.
nohup /tmp/script.sh &

这样做是在后台启动繁重的处理,但也将其与父进程断开连接,这样当父进程(实际启动脚本)终止时它不会自动终止。我们希望主启动脚本终止,以便将整个 VM 启动阶段标记为已完成。

有关详细信息,请参阅 Wikipedia page on nohup .

关于google-compute-engine - 启动脚本在停止之前是否有时间限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38211164/

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