Skip to content

Commit 5cbec3c

Browse files
committed
refactor(env): improve the env conf
1 parent d862160 commit 5cbec3c

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

src/cli/commands/env.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,28 @@ export async function cmdEnv(
5353
}
5454

5555
const namespace = getDeploymentName({ ...config, apps: [app] } as any);
56-
if (app.appType === 'backend' && namespace) {
57-
const nodeVersion = config.nodeVersion === 'lts' ? '24' : config.nodeVersion;
58-
const mise = `export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"`;
59-
const checkResult = await executor.exec(
60-
`${mise}; mise exec node@${nodeVersion} -- pm2 describe ${namespace} 2>/dev/null && echo "running" || echo "stopped"`,
61-
);
56+
if (!namespace) {
57+
ui.info(`No PM2 namespace configured for '${app.name}' — nothing to reload.`);
58+
continue;
59+
}
60+
61+
const nodeVersion = config.nodeVersion === 'lts' ? '24' : config.nodeVersion;
62+
const mise = `export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"`;
63+
const checkResult = await executor.exec(
64+
`${mise}; mise exec node@${nodeVersion} -- pm2 describe ${namespace} 2>/dev/null && echo "running" || echo "stopped"`,
65+
);
6266

63-
if (checkResult.stdout.includes('running')) {
64-
ui.info('Reloading deployment to pick up environment variables...');
65-
await executor.exec(
66-
`${mise}; mise exec node@${nodeVersion} -- pm2 reload ${namespace} --update-env`,
67-
);
68-
ui.success('Deployment reloaded with new environment variables');
69-
} else {
70-
ui.warn('Deployment not running. Variables will be loaded on next deploy.');
71-
}
67+
if (checkResult.stdout.includes('running')) {
68+
ui.info(`Reloading '${app.name}' (${namespace}) to pick up environment variables...`);
69+
await executor.exec(
70+
`${mise}; mise exec node@${nodeVersion} -- pm2 reload ${namespace} --update-env`,
71+
);
72+
ui.success(`'${app.name}' reloaded with new environment variables`);
73+
} else {
74+
ui.warn(
75+
`'${app.name}' (${namespace}) is not running on the server. ` +
76+
`Run 'shipnode deploy --app ${app.name}' to start it — new env will be picked up automatically.`,
77+
);
7278
}
7379
}
7480
},

0 commit comments

Comments
 (0)