用pm2 来接管hexo的进程
开始操作.安装pm2
1
$ npm  install -g pm2
写一个执行脚本.在博客根目录下面创建一个hexo_run.js
1
2
3
4
5
6
7
8
9
10
//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}');
})
运行脚本.在根目录下执行。
1
# pm2 start hexo_run.js

如果关闭,可以使用关闭命令。

1
pm2 stop hexo_run


Nodejs      Hexo

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!