我正在尝试开发一个角度通用的应用程序,部署在googleappengine NodeJS标准环境中。
node server.js
Process terminated because the request deadline was exceeded. (Error code 123)
.
package.json
启动命令是
"node server.js"
,而在附录yaml我仅声明如下:
runtime: nodejs8
.
服务器代码(在TS中,打包为JS和WebPack):
import { enableProdMode } from '@angular/core';
import * as ngUniversal from '@nguniversal/express-engine';
import * as compression from 'compression';
import * as express from 'express';
import * as path from 'path';
import * as detector from 'spider-detector';
import * as appServer from '../dist/server/main.js';
require('zone.js/dist/zone-node');
const ROOT = path.resolve();
enableProdMode();
const app = express();
// Server-side rendering
function angularRouter(req, res): void {
res.render('index', { req, res });
}
// Enable compression
app.use(compression());
// Check if the user is a bot
app.use(detector.middleware());
// Root route before static files, or it will serve a static index.html, without pre-rendering
app.get('/', angularRouter);
// Serve the static files generated by the CLI (index.html, CSS? JS, assets...)
app.use(express.static('client'));
// Configure Angular Express engine
app.engine('html', ngUniversal.ngExpressEngine({
bootstrap: appServer.AppServerModuleNgFactory
}));
app.set('view engine', 'html');
app.set('views', path.join(ROOT, 'client'));
app.listen(3000, () => {
console.log('Listening on http://localhost:3000');
});
在googlecloud控制台日志查看器中,我成功地看到了“监听”
http://localhost:3000