批量部署前端Node.js守护forever

下载node安装包

wget https://nodejs.org/dist/v9.10.1/node-v9.10.1-linux-x64.tar.gz

ansible-playbook配置forever文件

more /opt/shell/yaml/install_forever.yaml

- hosts: "{{ host }}"
  tasks:
    -  name: copy forever_file
       copy: src=/opt/shell/soft/forever dest=/usr/local/src    
    -  name: install forever
       shell: /bin/bash /usr/local/src/forever/install_forever.sh

执行ansible-playbook剧本

ansible-playbook -i 10.0.0.1, /opt/shell/yaml/install_forever.yaml -e "host=10.0.0.1" -k

安装forever脚本

more install_forever.sh

#!/bin/bash
cd /usr/local/src/forever
tar xf node-v9.10.1-linux-x64.tar.gz -C /usr/local
cd /usr/local/node-v9.10.1-linux-x64
./bin/node -v
ln -sv /usr/local/node-v9.10.1-linux-x64/bin/node /usr/bin/node
ln -sv /usr/local/node-v9.10.1-linux-x64/bin/npm /usr/bin/npm
npm i forever -g
ln -sv /usr/local/node-v9.10.1-linux-x64/bin/forever /usr/bin/forever

批量部署前端Node.js守护forever

上一篇:PHP设计模式之命令行模式(Command)代码实例大全(22)


下一篇:Penetration Test - Select Your Attacks(5)