use nodejs 16

This commit is contained in:
Your Name 2024-08-06 11:20:35 +07:00
parent c560a527f4
commit 9f9bb078eb
2 changed files with 44 additions and 68 deletions

View File

@ -1,65 +0,0 @@
#!/bin/bash
# xoa run tmux server lite trong rc.local
echo "setup rc.local"
echo '#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#/boot/fan.sh &
if [ ! -d /var/run/sshd ]; then
mkdir /var/run/sshd
chmod 0755 /var/run/sshd
systemctl restart ssh
fi
time_begin=$(date)
echo "Begin rc.local. Time restart: $time_begin" >> /root/monitor/log/rc_local.log
echo "nameserver 8.8.8.8" > /etc/resolv.conf
# tmux new -d -s server_js 'node /root/BiFace_Server_Config_API/server.js'
exit 0' > /etc/rc.local
# Cai dat PM2 run Server lite
sudo apt install npm
npm cache clean -f
npm install pm2 -g n
sudo n stable
pm2 install pm2-logrotate
cd /root/monitor/setup/
pm2 ecosystem
echo "
module.exports = {
apps : [
{
name: 'Server_lite',
cwd: '/root/BiFace_Server_Config_API',
script: 'server.js',
args: '',
interpreter: 'node',
restart_delay: 1000,
cron_restart: '0 0 * * *',
watch: false,
time: true
}
]
};
" > ecosystem.config.js
# Khởi chạy pm2 vs cấu hình vừa sửa
pm2 reload ecosystem.config.js
# Cài đặt pm2 khởi động cùng Win/Ubuntu
pm2 startup
# Copy-paste và chạy dòng script hiện trên màn hình
pm2 save
reboot
exit 0

View File

@ -105,12 +105,53 @@ sudo service apache2 restart
#
cd /root
git clone http://gitea.beetai.com/dongpd/BiFace_Server_Config_API.git
sudo apt-get install -y nodejs npm
sudo apt-get install -y nodejs-dev node-gyp libssl1.0-dev
sudo apt install -y npm
#sudo apt-get install -y nodejs npm
#sudo apt-get install -y nodejs-dev node-gyp libssl1.0-dev
#sudo apt install -y npm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
chmod +x ~/.nvm/nvm.sh
source ~/.bashrc
nvm install 16
npm install pm2@5.4.2 -g n
#sudo n stable
pm2 install pm2-logrotate
cd BiFace_Server_Config_API
npm install
cd /root/monitor/setup/
pm2 ecosystem
echo "
module.exports = {
apps : [
{
name: 'Server_lite',
cwd: '/root/BiFace_Server_Config_API',
script: 'server.js',
args: '',
interpreter: 'node',
restart_delay: 1000,
cron_restart: '0 0 * * *',
watch: false,
time: true
}
]
};
" > ecosystem.config.js
pm2 reload ecosystem.config.js
pm2 startup
pm2 save
#cd BiFace_Server_Config_API
#npm install
sudo bash /etc/rc.local
cd /var/www/html/BiFace_Server_Lite
sudo chmod 0777 db/app.db
echo "================================ setup serverlite done! ================================"