#!/bin/bash
cd /home/software/
wget https://nodejs.org/dist/v9.8.0/node-v9.8.0-linux-x64.tar.xz
tar -xvf node-v9.8.0-linux-x64.tar.xz -C /usr/local/
mv /usr/local/node-v9.8.0-linux-x64/ /usr/local/node9.8
echo "export NODE_HOME=/usr/local/node9.8" >> /etc/profile
echo "export PATH=\$NODE_HOME/bin:\$PATH" >> /etc/profile
sleep 5
source /etc/profile #这里需注意,有时候需手动执行下!!!
#yarn install
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum -y install yarn
#pm2 install
npm install -g pm2
#projrct
cd /project/node/admin.integral-mall #node目录为所有nodejs项目存放的目录
yarn install && yarn run build && pm2 start ./bin/www --name "admin"
cd ../enterprise-mall
yarn install && yarn run build && pm2 start ./bin/www --name "enterprise"
cd ../integral-mall
yarn install && yarn run build && pm2 start ./bin/www --name "mall"