fix: 修复应用键生成逻辑,确保键值不以斜杠开头

This commit is contained in:
2026-01-29 01:56:29 +08:00
parent 9051df7a37
commit 76a7dc0082

View File

@@ -13,7 +13,11 @@ const createRandomApp = (opts: { app: any, package: any, pwd: string, status?: s
} }
if (!app.key) { if (!app.key) {
const randomSuffix = Math.random().toString(36).substring(2, 8); const randomSuffix = Math.random().toString(36).substring(2, 8);
app.key = packageJson.basename || `${'unknown-app'}-${randomSuffix}`; let appKey: string = packageJson.basename || `${'unknown-app'}-${randomSuffix}`;
if (appKey.startsWith('/')) {
appKey = appKey.slice(1)
}
app.key = appKey;
} }
app.path = pwd; app.path = pwd;
if (app.type === 'pm2-system-app' && !app.pm2Options) { if (app.type === 'pm2-system-app' && !app.pm2Options) {