Catch

easy-mock私有服务器部署

下载easy-mock源码

首先要确保自己已安装了node环境及npm或yarn

cd /usr/local git clone https://github.com/easy-mock/easy-mock.git cd easy-mock yarn # 也可以 npm install

静态资源部署到CDN及文件上传目录设置

vim config/default.json

修改如下,注意upload.dirfe.publicPath

{ "port": 7300, "host": "0.0.0.0", "pageSize": 30, "proxy": false, "db": "mongodb://localhost/easy-mock", "unsplashClientId": "", "redis": { "keyPrefix": "[Easy Mock]", "port": 6379, "host": "localhost", "password": "", "db": 0 }, "blackList": { "projects": [], "ips": [] }, "rateLimit": { "max": 1000, "duration": 1000 }, "jwt": { "expire": "14 days", "secret": "shared-secret" }, "upload": { "types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"], "size": 5242880, "dir": "/data/wwwdata/easymock/upload", "expire": { "types": [".json", ".yml", ".yaml"], "day": -1 } }, "ldap": { "server": "", "bindDN": "", "password": "", "filter": { "base": "", "attributeName": "" } }, "fe": { "copyright": "Catch", "storageNamespace": "easy-mock_", "timeout": 25000, "publicPath": "https://bmt.edaoe.com/easymock/" } }

安装pm2

npm i pm2 -g

启动

测试环境

yarn dev

正式环境

yarn build # 把dist下面资源放至cdn,然后执行启动 NODE_ENV=production pm2 start app.js

关闭(正式)

pm2 stop all

开机启动

vim /etc/rc.d/rc.local

添加如下

# easymock启动 NODE_ENV=production pm2 start /usr/local/easymock/app.js