let pm2 use .env
This commit is contained in:
parent
4660da4631
commit
ab3593c77a
2
.gitignore
vendored
2
.gitignore
vendored
@ -42,3 +42,5 @@ yarn-error.log*
|
|||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
/app/generated/prisma
|
/app/generated/prisma
|
||||||
|
|
||||||
|
logs
|
||||||
@ -1,22 +1,46 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const dotenv = require('dotenv')
|
||||||
|
|
||||||
|
// 加载 .env 文件
|
||||||
|
const envConfig = dotenv.config({ path: path.resolve(__dirname, '.env') })
|
||||||
|
|
||||||
|
if (envConfig.error) {
|
||||||
|
console.error('Error loading .env file:', envConfig.error)
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
apps: [
|
apps: [
|
||||||
{
|
{
|
||||||
name: "WinupdateNeo",
|
name: 'winupdate-neo',
|
||||||
script: "bun",
|
script: 'bun',
|
||||||
args: "start",
|
args: 'run start',
|
||||||
cwd: "./",
|
cwd: __dirname,
|
||||||
instances: 1,
|
|
||||||
autorestart: true,
|
|
||||||
watch: false,
|
|
||||||
max_memory_restart: "1G",
|
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: "production",
|
...process.env,
|
||||||
PORT: 3000
|
// 显式设置关键环境变量
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
PORT: process.env.PORT || '12398',
|
||||||
|
DATABASE_URL: process.env.DATABASE_URL,
|
||||||
|
AUTH_USERNAME: process.env.AUTH_USERNAME,
|
||||||
|
AUTH_PASSWORD: process.env.AUTH_PASSWORD,
|
||||||
|
MINIO_ENDPOINT: process.env.MINIO_ENDPOINT,
|
||||||
|
MINIO_PORT: process.env.MINIO_PORT,
|
||||||
|
MINIO_USE_SSL: process.env.MINIO_USE_SSL,
|
||||||
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
||||||
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
||||||
|
MINIO_BUCKET_NAME: process.env.MINIO_BUCKET_NAME
|
||||||
},
|
},
|
||||||
env_development: {
|
instances: 1,
|
||||||
NODE_ENV: "development",
|
exec_mode: 'fork',
|
||||||
PORT: 3000
|
watch: false,
|
||||||
}
|
max_memory_restart: '1G',
|
||||||
|
error_file: './logs/err.log',
|
||||||
|
out_file: './logs/out.log',
|
||||||
|
log_file: './logs/combined.log',
|
||||||
|
time: true,
|
||||||
|
autorestart: true,
|
||||||
|
max_restarts: 10,
|
||||||
|
min_uptime: '10s'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user