Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Azure上的NodeJs-站点无法加载_Node.js_Azure_Azure Web App Service - Fatal编程技术网

Node.js Azure上的NodeJs-站点无法加载

Node.js Azure上的NodeJs-站点无法加载,node.js,azure,azure-web-app-service,Node.js,Azure,Azure Web App Service,我在Azure上有一个非常简单的expressJs应用程序,从3月份开始,一切都很好 今天我去了网站,我发现一个“服务不可用”作为输出。。。在重新发布网站后,我在日志中发现了很多奇怪的错误,这些错误毫无意义: 从https://.scm.azurewebsites.net/api/logstream 2018-05-03T23:11:48 Updating branch 'master'. 2018-05-03T23:11:52 Updating submodules. 2018-05-03

我在Azure上有一个非常简单的expressJs应用程序,从3月份开始,一切都很好

今天我去了网站,我发现一个“服务不可用”作为输出。。。在重新发布网站后,我在日志中发现了很多奇怪的错误,这些错误毫无意义:

https://.scm.azurewebsites.net/api/logstream

2018-05-03T23:11:48  Updating branch 'master'.
2018-05-03T23:11:52  Updating submodules.
2018-05-03T23:11:52  Preparing deployment for commit id '7579046ef3'.
2018-05-03T23:11:56  Generating deployment script.
2018-05-03T23:11:56    Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "/home/site/repository" -o "/home/site/deployments/tools" --node --sitePath "/home/site/repository"').
2018-05-03T23:11:56  Running deployment command...
2018-05-03T23:11:56    Command: "/home/site/deployments/tools/deploy.sh"
2018-05-03T23:11:59    Handling node.js deployment.
2018-05-03T23:11:59    Kudu sync from: '/home/site/repository' to: '/home/site/wwwroot'
2018-05-03T23:11:59    Copying file: '.editorconfig'
2018-05-03T23:11:59    Copying file: '.eslintrc.js'
2018-05-03T23:11:59    Copying file: '.gitignore'
2018-05-03T23:11:59    Copying file: 'Procfile'
2018-05-03T23:12:00    Copying file: 'bitbucket-pipelines.yml'
2018-05-03T23:12:00    Copying file: 'package-lock.json'
2018-05-03T23:12:00    Copying file: 'package.json'
2018-05-03T23:12:00    Copying file: 'readme.md'
2018-05-03T23:12:00    Ignoring: .git
2018-05-03T23:12:00    Copying file: '.vscode/launch.json'
2018-05-03T23:12:00    Copying file: 'public/favicon.ico'
2018-05-03T23:12:00    Copying file: 'public/swagger.html'
2018-05-03T23:12:00    Copying file: 'public/swagger.json'
2018-05-03T23:12:00    Copying file: 'public/swagger.yaml'
2018-05-03T23:12:00    Copying file: 'server/server.js'
2018-05-03T23:12:00    Copying file: 'server/models/dtlCall.js'
2018-05-03T23:12:00    Copying file: 'server/models/dtlError.js'
2018-05-03T23:12:00    Copying file: 'server/routes/dtl.js'
2018-05-03T23:12:00    Copying file: 'server/routes/index.js'
2018-05-03T23:12:01    Copying file: 'server/utilities/auth.js'
2018-05-03T23:12:01    Copying file: 'server/utilities/error.js'
2018-05-03T23:12:01    Copying file: 'server/utilities/index.js'
2018-05-03T23:12:01    Copying file: 'server/utilities/logger.js'
2018-05-03T23:12:01    Copying file: 'test/common.js'
2018-05-03T23:12:01    Copying file: 'test/mocha.opts'
2018-05-03T23:12:01    Copying file: 'test/config/employees.result.json'
2018-05-03T23:12:01    Copying file: 'test/config/payload.json'
2018-05-03T23:12:01    Copying file: 'test/server/auth.js'
2018-05-03T23:12:01    Copying file: 'test/server/utilities.js'
2018-05-03T23:12:01    Copying file: 'views/default.html'
2018-05-03T23:12:01    Copying file: 'views/default.pug'
2018-05-03T23:12:01    Detecting node version spec...
2018-05-03T23:12:01    Using package.json engines.node value: 8.9.x
2018-05-03T23:12:02    Node.js versions available on the platform are: 4.4.7, 4.5.0, 6.2.2, 6.6.0, 6.9.3, 6.10.3, 6.11.0, 8.0.0, 8.1.0, 8.2.1, 8.8.1, 8.9.4, 9.4.0.
2018-05-03T23:12:02    Resolved to version 8.9.4
2018-05-03T23:12:02    Detecting npm version spec...
2018-05-03T23:12:02    Using package.json engines.npm value: 5.0.x
2018-05-03T23:12:02    NPM versions available on the platform are: 2.15.8, 2.15.9, 3.9.5, 3.10.3, 3.10.10, 5.0.3.
2018-05-03T23:12:02    Resolved to version 5.0.3
2018-05-03T23:12:02    Running "/opt/nodejs/8.9.4/bin/node" "/opt/npm/5.0.3/node_modules/npm/bin/npm-cli.js" install --production
2018-05-03T23:12:02    npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /opt/nodejs/8.9.4/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
2018-05-03T23:12:13    npm WARN dtl_api@1.0.0 No repository field.
2018-05-03T23:12:13    removed 5 packages in 10.288s
2018-05-03T23:12:13    
2018-05-03T23:12:13    Finished successfully.
2018-05-03T23:12:13  Running post deployment command(s)...
2018-05-03T23:12:13  Deployment successful.
2018-05-03T23:12:14  App container will begin restart within 10 seconds.

2018-05-03 23:12:57.683 INFO  - Starting container for site
2018-05-03 23:12:57.684 INFO  - docker run -d -p 15062:8080 --name bb-dtl-service__9e0a_0 -e WEBSITE_NODE_DEFAULT_VERSION=8.9 -e APPSETTING_WEBSITE_NODE_DEFAULT_VERSION=8.9 -e WEBSITE_SITE_NAME=bb-dtl-service -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=fb29dfd8d91e0378f3794f42c27d2c348a5c5eb0bfc876bcc540f651b3082330 -e HTTP_LOGGING_ENABLED=1 appsvc/node:8.9.4_1804040228 ./server/server.js 

2018-05-03T23:12:59.263038964Z Starting OpenBSD Secure Shell server: sshd.
2018-05-03T23:12:59.525171581Z Generating app startup command
2018-05-03T23:12:59.538785224Z Running ./server/server.js
2018-05-03T23:12:59.559830590Z /home/site/wwwroot/server/server.js: line 1: syntax error near unexpected token `('
2018-05-03T23:12:59.559958090Z /home/site/wwwroot/server/server.js: line 1: `const express = require('express');'

2018-05-03 23:13:00.286 ERROR - Container bb-dtl-service__9e0a_0 for site bb-dtl-service__9e0a has exited, failing site start
我的
server/server.js
文件内容是

const express = require('express');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const helmet = require('helmet');
const favicon = require('serve-favicon');
const path = require('path');

const app = express();

// ======================= configuration =================================
const port = process.env.PORT || 4006;
const env = process.env.APP_ENVIRONMENT || 'unknown';

// view engine
app.set('view engine', 'pug');
app.use(express.static('public'));

// favicon
app.use(favicon(path.join(`${__dirname}/../`, 'public', 'favicon.ico')));

// use body parser so we can get info from POST and/or URL parameters
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// using morgan to log requests to the console
app.use(morgan(':remote-addr ":referrer" ":user-agent" :method :url :status - :response-time ms'));

// https://blog.risingstack.com/node-js-security-checklist/
app.use(helmet());

// ======================= routes ========================================
const apiRoutes = require('./routes');

// API ROUTES ------------------------------------------------------------
app.use('/api', apiRoutes);

// OTHER ROUTES ----------------------------------------------------------
app.get('/swagger-ui', (req, res) => {
    // show the swagger definition reader
    // html file from https://github.com/csabapalfi/swagger-ui-min
    res.redirect('/swagger.html');
});
app.all('*', (req, res) => {
    // get last commit id and show it on the page
    const lastCommitHash = process.env.SOURCE_VERSION || '';
    const lastCommitShor = lastCommitHash.length > 8 ? lastCommitHash.substr(0, 8) : '';
    res.render('default', { gitHash: lastCommitHash, gitShortHash: lastCommitShor, env });
});

// ======================= start the server ==============================
app.listen(port, () => {
    console.log(`Magic happens at http://localhost:${port}`); // eslint-disable-line
});

exports.server = app; // export for testing

有人知道发生了什么事吗

为什么集装箱不能接受那条线

自从三月份以来,一切都很顺利,为什么现在会出现错误呢

我已经试了两个小时了,没有任何意义:(


我的应用程序设置


5月9日更新

创建了一个简单的
Dockerfile

FROM mhart/alpine-node

RUN mkdir -p /app
ADD . /app
WORKDIR /app

RUN npm install && npm update https-proxy-agent --depth 2

CMD npm start
作为:


所以,即使在docker上,所有的工作都是正常的://

你有没有检查过编码问题?常见的
CRLF
&
LF
问题?@JerryLiu在这样的版本上应该没有任何意义,那是在那个时代……顺便说一句,相同的提交代码在Heroku和本地运行,没有任何更改:o(只是一个建议,因为我发现半年前有人遇到过类似的问题。@JerryLiu检查了所有文件,所有文件都以
LF
结尾,创建了docker文件并从docker运行代码,尽管使用
mhart/alpine node
而不是Azure特定的图像…运行良好:(在iisnode配置中启用
deverrorEnabled
,应该会显示真正的问题。
docker build .
docker run -it -p 8080:4006 -e "MONGODB_URI=mongodb://dbuser:dbpass@dsxxxxxx.mlab.com:19080/mongocollection" 5067e22e341b

> dl_api@1.0.0 start /app
> node ./server/server.js

Magic happens at http://localhost:4006