源码部署
通过源码编译部署 Mix Space 后端
如果你不是开发者,或者不想折腾,请不要选择源码部署。由于自身技术原因导致的问题,我们将不会提供任何技术支持。
要求
克隆并安装
git clone https://github.com/mx-space/core.git --depth=1
cd core
pnpm i构建 & Bundle
pnpm build
pnpm bundle配置 ecosystem.config.js
在 ./apps/core 目录下创建 ecosystem.config.js:
const { cpus } = require('os')
const { execSync } = require('child_process')
const nodePath = execSync(`npm root --quiet -g`, { encoding: 'utf-8' }).split(
'\n',
)[0]
const cpuLen = cpus().length
module.exports = {
apps: [
{
name: 'mx-server',
script: './out/index.js',
autorestart: true,
exec_mode: 'cluster',
watch: false,
instances: cpuLen,
max_memory_restart: '520M',
args: '',
env: {
NODE_ENV: 'production',
NODE_PATH: nodePath,
// 必填:允许跨域的域名,多个用逗号分隔
ALLOWED_ORIGINS: 'your-domain.com',
// 必填:JWT 密钥,16-32 个字符
JWT_SECRET: 'your-jwt-secret',
// 可选:加密密钥,开启加密时填写
MX_ENCRYPT_KEY: '',
},
},
],
}环境变量
更多环境变量配置请参考 环境变量说明。