运行 Node.js 在 Google Cloud Shell – 它是免费的吗?

Running Node.js in Google Cloud Shell – Is it Free?

我对这一切都很陌生,所以请告诉我我做错了什么!

我使用 Node.js 为 Discord 编写了一个小机器人。

我还注册了 Google Cloud Platform 的免费试用,赠金 300 美元等等。创建项目后,我启动了云 shell 和 运行 我的 Node.js Discord 机器人使用:

node my_app_here.js

云 shell 正在 运行ning,机器人工作正常。会不会云shell运行无限期地保持我的bot运行ning?似乎很难相信 Google 会免费托管我的机器人。我在该项目上禁用了计费,但我害怕收到巨额账单。

感谢您的帮助或建议!

它是免费的,但旨在用于交互式使用。我想您可以将它用于其他目的,但这可能会很麻烦。如果您想免费使用,可以考虑您尝试做的事情是否适合 google app engine standard environment.

的免费套餐

Cloud Shell is intended for interactive use only. Non-interactive sessions will be ended automatically after a warning. Prolonged usage or computational or network intensive processes are not supported and may result in session termination without a warning.

Documentation

您可以在代码末尾使用此代码来保持它的活动状态:

function intervalFunc() {
  const { exec } = require("child_process");

exec("ls -la", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }     
},)}

setInterval(intervalFunc, 3600000 )});