Javascript 函数执行耗时60060毫秒,状态为&x27;超时';。谷歌云功能

Javascript 函数执行耗时60060毫秒,状态为&x27;超时';。谷歌云功能,javascript,express,google-app-engine,google-cloud-functions,Javascript,Express,Google App Engine,Google Cloud Functions,我试图上传我在谷歌云函数上的nodejs工作,但我在日志中遇到超时错误。我正在尝试使用模板加载主页。我无法正确使用helloworld函数。下面是代码的一部分,而不是完整的代码 exports.helloworld = ()=>{ app.get('/',(req, res)=> { res.render('home'); }); } app.listen(3000, () => { console.log('app now liste

我试图上传我在谷歌云函数上的nodejs工作,但我在日志中遇到超时错误。我正在尝试使用模板加载主页。我无法正确使用helloworld函数。下面是代码的一部分,而不是完整的代码

exports.helloworld = ()=>{
    app.get('/',(req, res)=> {
        res.render('home');
    });
}

app.listen(3000, () => {
    console.log('app now listening for requests on port 3000');
});

如果要在云功能中使用express js路由,则需要导出express js应用程序,而不是运行服务器

index.js

const express = require('express');
const app = express();
app.get('/',(req, res)=> {
    res.render('home');
});
app.get('/login',(req, res)=> {
    res.render('login');
});
exports.helloworld = app;

云函数不支持编写侦听端口的代码。云函数管理套接字,您只需编写触发器代码。我建议回到文档并遵循其示例。