We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
文件更新自动重载
const fs = require('fs'), path = require('path'), projectRootPath = path.resolve(__dirname, './src'); const watch = project => { require('./src'); // 启动 APP,自动检索到 src/index.js try { // 监听文件夹 fs.watch(project, { recursive: true }, cacheClean) } catch(e) { console.error('watch file error'); } } // 清除缓存 const cacheClean = () => { Object.keys(require.cache).forEach(function (id) { if (/[\/\\](src)[\/\\]/.test(id)) { delete require.cache[id] } }) } // 启动开发模式 watch(projectRootPath);
or
const pm2 = require('pm2'); pm2.connect(function(err) { if (err) { console.error(err); process.exit(2); } pm2.start({ "watch": ["./app"], // 开启 watch 模式,并监听 app 文件夹下的改动 "ignore_watch": ["node_modules", "assets"], // 忽略监听的文件 "watch_options": { "followSymlinks": false // 不允许符号链接 }, name: 'httpServer', script: './server/index.js', // APP 入口 exec_mode: 'fockMode', // 开发模式下建议使用 fockModel instances: 1, // 仅启用 1 个 CPU max_memory_restart: '100M' // 当占用 100M 内存时重启 APP }, function(err, apps) { pm2.disconnect(); // Disconnects from PM2 if (err) throw err }); });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
文件更新自动重载
or
The text was updated successfully, but these errors were encountered: