企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
node的方式 - ~~~ var gaze = require("gaze"); var exec = require('child_process').exec; var fs = require("fs"); function init(){ fs.mkdirSync('./api'); fs.mkdirSync('./doc'); createConfigureFile(); beginWatch(); } function createConfigureFile(){ var configure = { "name": "API接口-捣蛋熊猫", "version": "1.0.0", "title": "捣蛋熊猫接口文档", "url": "http://testwx.lifephp.cn", "template": { "withCompare":false, "forceLanguage":"zh_cn", "withGenerator":false } }; fs.writeFileSync('./api/apidoc.json',JSON.stringify(configure)); } function beginWatch(){ gaze('../../application/wechat/*.php',function(error,watcher){ this.on('all', function(event, filepath) { console.log(filepath + ' was ' + event); runGeneartion(); }) }); } function runGeneartion(){ var com = exec('apidoc -i ../../application/wechat/ -o ./doc -t ./tpl') com.stdout.on('data', function (data) { console.log("生成Api->"+data); }); com.stderr.on('data', function (data) { console.log('生成错误啦->' + data); }); } if(fs.existsSync('./api') && fs.existsSync('./doc')){ beginWatch(); }else{ init(); } ~~~ fswatch - ~~~ #!/bin/bash DIR=$1 if [ ! -n "$DIR" ] ;then echo "you have not choice Application directory !" exit fi php easyswoole stop php easyswoole start --d fswatch $DIR | while read file do echo "${file} was modify" >> ./Temp/reload.log 2>&1 php easyswoole reload done ~~~ 执行时只能检测一个文件夹,多了不行