zoukankan      html  css  js  c++  java
  • Centos里开机自启动Node 服务程序

    Centos里开机自启动Node 服务程序

    第一种:

    vim /data/www/community-5050/start.sh

    #!/bin/bash
    . /etc/profile
    su -c "cd /data/www/community-5050;nohup cnpm run start >> /data/logs/community-5050/community.log 2>&1 &" dev

    vim /etc/rc.d/rc.local

    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local
    /bin/bash /data/www/community-5050/start.sh

    授权:

    chmod +x /data/www/community-5050/start.sh
    chmod +x /etc/rc.d/rc.local

    第二种:

    [root@node1 ~]# vim /data/scripts/node_enable.sh

    #!/bin/bash
    PROJECT="$1"
    LISTEN_PORT="$2"
    WEB_BASE="/data/www"
    STARTUP="nohup cnpm run start"
    
    cd $WEB_BASE/$PROJECT-${LISTEN_PORT}
    su -c "$STARTUP >> /data/logs/$PROJECT-$LISTEN_PORT/$PROJECT.log 2>&1 &" dev

    [root@node1 ~]# vim /etc/rc.d/rc.local

    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local
    /data/scripts/node_enable.sh community 5050

    授权:

    [root@node1 ~]# chmod +x /data/scripts/node_enable.sh
    [root@node1 ~]# chmod +x /etc/rc.d/rc.local 
  • 相关阅读:
    Map,Multimap,Set,MultiSet,Hash_Map,Hash_Set,Share_ptr的区分
    mjpgstreamer源码分析
    S3C2410x介绍
    V4L2应用程序框架
    V4L2驱动框架
    Linux 视频设备驱动V4L2最常用的控制命令使用说明
    (转)在eclipse中查看android SDK的源代码
    [经验技巧] 利用WindowsPhone7_SDK_Full.rar_for_xp,在xp下安装sdk,部署xap软件的教程
    (收藏)智能手机开发
    Html5相关文章链接
  • 原文地址:https://www.cnblogs.com/xuanbao/p/13086600.html
Copyright © 2011-2022 走看看