add pm2 config
This commit is contained in:
parent
9647b7d3c9
commit
0ac78815ae
@ -0,0 +1,31 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { withCors } from '@/lib/middleware'
|
||||
|
||||
async function handleGetVersion(req: NextRequest) {
|
||||
try {
|
||||
const latestVersion = await prisma.version.findFirst({
|
||||
where: { isLatest: true }
|
||||
})
|
||||
|
||||
if (!latestVersion) {
|
||||
return NextResponse.json({ error: 'No version found' }, { status: 404 })
|
||||
}
|
||||
|
||||
const protocol = req.headers.get('x-forwarded-proto') || 'http'
|
||||
const host = req.headers.get('host')
|
||||
const downloadUrl = `${protocol}://${host}/api/downloads/${latestVersion.fileId}`
|
||||
|
||||
return NextResponse.json({
|
||||
version: latestVersion.version,
|
||||
download_url: downloadUrl,
|
||||
checksum: latestVersion.checksum
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取版本信息失败:', error)
|
||||
return NextResponse.json({ error: '获取版本信息失败' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
export const GET = withCors(handleGetVersion)
|
||||
22
pm2.config.js
Normal file
22
pm2.config.js
Normal file
@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: "winupdate-neo",
|
||||
script: "bun",
|
||||
args: "start",
|
||||
cwd: "./",
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: "1G",
|
||||
env: {
|
||||
NODE_ENV: "production",
|
||||
PORT: 3000
|
||||
},
|
||||
env_development: {
|
||||
NODE_ENV: "development",
|
||||
PORT: 3000
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user