I created a (standard) nodejs app on Google Cloud App engine. My aim is to build a background job app which will only send http requests to another server every x seconds.
// index.js
const winston = require("winston");
const { LoggingWinston } = require("@google-cloud/logging-winston");
const loggingWinston = new LoggingWinston();
const logger = winston.createLogger({
level: "info",
transports: [new winston.transports.Console(), loggingWinston],
});
logger.info("started");
const pingLoop = () =>
setTimeout(function () {
logger.info("ping");
// send HTTP request
pingLoop();
}, 10000);
pingLoop();
Deploying the app seems to work fine gcloud app deploy --project=project-name.
However, I can't see any logs when I run gcloud app logs tail --project=project-name
Waiting for new log entries...
My package.json
{
"name": "test-nodejs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@google-cloud/logging-winston": "^4.0.4",
"winston": "^3.3.3"
}
}
and app.yaml
runtime: nodejs12
Are background jobs supposed to work on Google App engine?