[英]How to deploy nodejs expressjs app in Azure with CI/CD?
I'm trying to deploy a nodejs with expressjs app.我正在尝试使用 expressjs 应用程序部署 nodejs。 My pipeline is this:
我的管道是这样的:
This create a correct artifact:这将创建一个正确的工件:
We can check here:我们可以在这里查看:
Now I create this release that uses the artifact I mentioned previously:现在我创建这个版本,它使用我之前提到的工件:
The steps in release:发布步骤:
And after release executed(success) in appname.scm.azurewebsites.net in wwwroot folder I have the right files:在 wwwroot 文件夹中的 appname.scm.azurewebsites.net 中执行(成功)发布后,我有正确的文件:
But application never start because I never tell how start I think.
但是应用程序永远不会启动,因为我从不说出我的想法。
What would I put in Post deployment action?我会在部署后操作中加入什么? node server/server.js?
节点服务器/server.js? (server.js is in server folder), npm start?
(server.js 在服务器文件夹中),npm 启动? In my package.json if I use npm start, then it going to run node server/server.js.
在我的 package.json 中,如果我使用 npm 启动,那么它将运行 node server/server.js。 Because in local, if I will run my app I have to execute npm start or node server/server.js
因为在本地,如果我要运行我的应用程序,我必须执行 npm start 或 node server/server.js
In the package.json
file, normally you set the main file, "main": "server.js"
, in your case I think you should define main as "main": "server.js"
and move the server.js file from the server directory to project root directory
.在
package.json
文件中,通常您设置主文件"main": "server.js"
,在您的情况下我认为您应该将 main 定义为"main": "server.js"
并将 server.js 文件从服务器目录到项目root directory
。
If you look at the log stream, normally to start the project, azure runs node server
or something you defined in the package.json
as main.如果您查看日志 stream,通常启动项目,azure 运行
node server
或您在package.json
中定义为主要的东西。
I have pasted some parts of the azure log stream here so you can see what happens in the azure:我在这里粘贴了 azure 日志 stream 的一些部分,这样您就可以看到 azure 中发生了什么:
2022-05-09T18:19:04.222521897Z # Enter the source directory to make sure the script runs where the user expects
2022-05-09T18:19:04.222528898Z cd "/home/site/wwwroot"
2022-05-09T18:19:04.222535898Z
2022-05-09T18:19:04.222542298Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2022-05-09T18:19:04.222548498Z if [ -z "$PORT" ]; then
2022-05-09T18:19:04.222554799Z export PORT=8080
2022-05-09T18:19:04.222561899Z fi
2022-05-09T18:19:04.222783509Z
2022-05-09T18:19:04.222805710Z node server.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.