I am trying to build release pipeline using classic azure pipelines for nextjs project to deploy it on self hosted windows server and I used iis as a redirection server to the nextjs application, my issue is how can I keep the nextjs application running to enable redirection to it from iis?
tasks which I used
steps:
- task: NodeTool@0
displayName: 'Use Node 20.x'
inputs:
versionSpec: 20.x
steps:
- powershell: |
npm i
workingDirectory: 'some directory'
displayName: 'npm i'
steps:
- powershell: |
npm install pm2 -g
workingDirectory: 'some directory'
displayName: 'npm install pm2 -g'
steps:
- powershell: 'pm2-runtime start ecosystem.config.js --env production'
workingDirectory: 'some directory'
displayName: 'pm2-runtime start ecosystem.config.js --env production'
env:
HOME: ~
I can reproduce the same situation when using the same pm2-runtime start command.
The Pipeline will keep running after the app starting.
As far as I know, pm2-runtime designed for Docker container which keeps an application in the foreground which keep the container running,
pm2 is designed for normal usage where you send or run the application in the background.
To solve this issue, you can change to use the pm2 command for the react.js app on windows:
pm2 start ecosystem.config.js --env production --watch
Result:
Update:
To avoid the Finalize job clean the process, you can set the variable: process.clean = false
in Release Pipeline
Result: