vue pm2守护进程

Linux

  • 创建一个.sh可执行脚本,例如hexo.sh

    • 代码
      1
      2
       #!/usr/bin/env bash
      hexo server
  • 使用pm2 start hexo.sh执行脚本

Windows

  • 创建一个JS文件,例如名字为app.js

    • 代码
      1
      2
      3
      4
      5
      6
      7
      8
      9
         const { exec } = require('child_process')
      exec('hexo s',(error, stdout, stderr) => {
      if(error){
      console.log(`exec error: ${error}`)
      return
      }
      console.log(`stdout: ${stdout}`);
      console.log(`stderr: ${stderr}`);
      })
  • 使用pm2 start app.js执行文件

原文地址:https://www.cnblogs.com/ldms/p/3152601.html