开始操作※
安装pm2※
sudo npm install -g pm2
写一个执行脚本※
在博客根目录下面创建一个 hexo_run.js
//run
const { exec } = require('child_process')
exec('hexo server',(error, stdout, stderr) => {
if(error){
console.log('exec error: ${error}')
return
}
console.log('stdout: ${stdout}');
console.log('stderr: ${stderr}');
})
运行脚本※
在根目录下
pm2 start hexo_run.js
就可以使得hexo常驻后台了。