代码之家  ›  专栏  ›  技术社区  ›  gmaniac

supervisord放弃nodejs进入致命状态

  •  0
  • gmaniac  · 技术社区  · 10 年前

    我正在将节点应用程序部署到aws-eb,这是我的 Dockerfile

    FROM    ubuntu:14.04
    
    RUN rm /bin/sh && ln -s /bin/bash /bin/sh
    
    # Install base packages
    ENV DEBIAN_FRONTEND noninteractive
    RUN apt-get update && apt-get install -y \
        zsh \
        vim \
        git \
        curl \
        build-essential \
        nodejs \
        npm \
        supervisor
    
    RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
    
    RUN mkdir -p /var/run/sshd /var/log/supervisor
    
    COPY build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
    
    RUN mkdir -p /app
    ADD api/ /app
    
    RUN cd /app && npm install
    
    WORKDIR /app
    
    EXPOSE 8090
    
    CMD ["/usr/bin/supervisord"]
    

    这是我的 supervisord.conf

    [supervisord]
    nodaemon=true
    
    [program:nodejs]
    directory=/app
    command=node server.js web
    autorestart = true
    stdout_logfile=/var/log/%(program_name)s.log
    stderr_logfile=/var/log/%(program_name)s.log
    

    这是我的 stdouterr.log

    /usr/lib/python2.7/dist-packages/supervisor/options.py:295: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
    'Supervisord is running as root and it is searching '
    2016-04-08 16:48:37,892 CRIT Supervisor running as root (no user in config file)
    2016-04-08 16:48:37,892 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
    2016-04-08 16:48:37,909 INFO RPC interface 'supervisor' initialized
    2016-04-08 16:48:37,909 CRIT Server 'unix_http_server' running without any HTTP authentication checking
    2016-04-08 16:48:37,910 INFO supervisord started with pid 1
    2016-04-08 16:48:38,912 INFO spawned: 'nodejs' with pid 11
    2016-04-08 16:48:39,332 INFO exited: nodejs (exit status 8; not expected)
    2016-04-08 16:48:40,334 INFO spawned: 'nodejs' with pid 13
    2016-04-08 16:48:40,732 INFO exited: nodejs (exit status 8; not expected)
    2016-04-08 16:48:42,736 INFO spawned: 'nodejs' with pid 15
    2016-04-08 16:48:43,414 INFO exited: nodejs (exit status 8; not expected)
    2016-04-08 16:48:46,419 INFO spawned: 'nodejs' with pid 17
    2016-04-08 16:48:47,288 INFO exited: nodejs (exit status 8; not expected)
    2016-04-08 16:48:48,289 INFO gave up: nodejs entered FATAL state, too many start retries too quickly
    

    在这一点上,任何建议都是有帮助的。

    1 回复  |  直到 8 年前
        1
  •  0
  •   gmaniac    10 年前

    正如@AssafLavie在评论中提到的,节点应用程序正在崩溃。它崩溃的原因是因为我必须设置 node npm 版本转换为我的指定版本 package.json 文件

    我的 Dockerfile 现在看起来像

    FROM    ubuntu:14.04
    
    RUN rm /bin/sh && ln -s /bin/bash /bin/sh
    
    # Install base packages
    ENV DEBIAN_FRONTEND noninteractive
    RUN apt-get update && apt-get install -y \
        zsh \
        vim \
        git \
        curl \
        build-essential \
        nodejs \
        npm \
        supervisor
    
    RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
    
    # Added the following 5 lines
    
    RUN npm install -g n
    
    RUN n 5.0.0
    
    RUN rm /usr/bin/node
    RUN ln -s /usr/local/bin/node /usr/bin/node
    
    RUN npm install npm@3.8.5 -g
    
    # End of the added lines to specify node and npm versions
    
    RUN mkdir -p /var/run/sshd /var/log/supervisor
    
    COPY build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
    
    RUN mkdir -p /app
    ADD api/ /app
    
    RUN cd /app && npm install
    
    WORKDIR /app
    
    EXPOSE 8090
    
    CMD ["/usr/bin/supervisord"]