PM2 错误:app=npm id=0 没有 pid

问题描述 投票:0回答:1

让 docker 文件包含以下步骤,镜像构建成功,如果您检查日志,服务器也在以下端口上成功启动,但不确定是否面临 pm2 的此错误,并且 pm2 停止,请参阅日志。 因此,我们使用 azure 进行部署,通过 azure cli 我可以看到部署、服务和 Pod 已成功创建。 一旦服务器启动并与 mongo 建立连接,pm2 会突然尝试杀死 pid,但失败并最终停止 有人可以帮忙或指出正确的方向或出现此错误的原因吗

Docker 文件步骤

FROM node:14.21.2-alpine
# Set the source folder
ARG SOURCE_FOLDER="./"

######################
ENV PYTHONUNBUFFERED=1
RUN apk update && apk add bash
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools

# Create the lscservices.sh for the services start command
RUN touch lscservices.sh && \
 chmod 700 lscservices.sh && \
 echo -e '#!/bin/bash\nlsc services start' > lscservices.sh && \
 mv lscservices.sh /usr/bin/
WORKDIR /labshare/communities-api
ARG NPM_TOKEN
COPY . .
# COPY package.json and project .
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
RUN apk add --no-cache --virtual .gyp python3 make g++
RUN rm -rf node_modules
RUN rm -rf dist
RUN npm cache clean --force
RUN rm package-lock.json
RUN npm install
RUN npm i pm2@latest -g
RUN npm i bash -g
RUN npm -g config set user root
RUN npm install @labshare/lsc -g
RUN npm install typescript -g
RUN npm run build
RUN rm -f .npmrc

# Run the service using pm2 and the shorcut to lsc start services
CMD ["pm2-docker","lscservices.sh"]
#CMD ["pm2-runtime", "npm", "start" ]
EXPOSE 8000

日志:

2023-06-22T12:37:53: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]stdout            
       2023-06-22T12:37:53: PM2 log: Script /usr/local/bin/npm had too many unstable restarts (16). Stopped. "errored"stdout
       2023-06-22T12:37:55: PM2 log: 0 application online, retry = 3 
 stdout
       2023-06-22T12:37:57: PM2 log: 0 application online, retry = 2 
 stdout
       2023-06-22T12:37:59: PM2 log: 0 application online, retry = 1 
 stdout
       2023-06-22T12:38:01: PM2 log: 0 application online, retry = 0 
stdout
2023-06-22T16:39:46.559Z info: LabShare services listening at http://:::8000  stdout
2023-06-22T12:38:01: PM2 log: Stopping app:npm id:0    stdout
2023-06-22T12:38:01: PM2 error: app=npm id=0 does not have a pid stderr
2023-06-22T12:38:01: PM2 log: PM2 successfully stopped stdout
2023-06-22T12:39:38: PM2 log: Launching in no daemon mode    stdout
2023-06-22T12:39:38: PM2 log: App [lscservices:0] starting in -fork mode-    stdout

2023-06-22T12:39:38: PM2 log: App [lscservices:0] online

一切都很好,我最近遇到了这个错误,我们使用 14.2.1 alpine 图像作为节点,最新版本的 pm2

node.js azure docker dockerfile pm2
1个回答
0
投票

对于 NextJS 设置,同样的错误,将

ecosystem.config.js
文件更改为:

script: "./node_modules/.bin/next",
args: 'start',

script: "./node_modules/.bin/next start",

有帮助

© www.soinside.com 2019 - 2024. All rights reserved.