zoukankan      html  css  js  c++  java
  • centos下forever安装nodejs服务

    1.安装nodejs和forever    npm install forever -g

    2.制作自己nodejs的自启动文件,在此为express框架,放在/etc/init.d/***

    确定网站所在文件夹(/root/ImageServer),以及执行文件(bin/www)

    #!/bin/bash
    #
    # node Start up node server daemon
    #
    # chkconfig: 345 85 15
    # description: Forever for Node.js
    #
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    LOG=/work/server/hosts_log
    PID=/work/server/forever.pid

    function start_app {
    cd /root/ImageServer;
    forever start "bin/www" -l $LOG/forever.log -o $LOG/forever_out.log -e $LOG/forever_err.log --pidFile $PID
    }
    function stop_app {
    cd /root/ImageServer;
    forever stop "bin/www"
    }

    case $1 in
    start)
    start_app ;;
    stop)
    stop_app ;;
    restart)
    stop_app
    start_app
    ;;
    *)
    echo "usage: clearstonecc {start|stop}" ;;
    esac
    exit 0

    3.确认文件属性  sudo chmod 755 /etc/init.d/***

    4.启动服务

    sudo chkconfig -add ***

    chkconfig *** on

    5.控制服务

    service *** start

    service *** stop

    service *** restart

  • 相关阅读:
    flex
    当前不会命中断点 源代码与原始版本不一致
    c setjmp longjmp
    VS 快捷键设置
    Lua C API 遍历 table
    lua class
    复习 C++ 中类的函数指针
    apache ab
    rabbitmq
    协程 coroutine
  • 原文地址:https://www.cnblogs.com/lovesumer/p/5506129.html
Copyright © 2011-2022 走看看