agent-window 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api/routes/operations.js +13 -1
package/package.json
CHANGED
|
@@ -107,7 +107,19 @@ export async function registerOperationRoutes(fastify) {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
// Check if process already exists in PM2
|
|
111
|
+
const { getProcess } = await import('../../core/instance/pm2-bridge.js');
|
|
112
|
+
const existingProc = await getProcess(botName);
|
|
113
|
+
|
|
114
|
+
let result;
|
|
115
|
+
if (existingProc && existingProc.status !== 'stopped') {
|
|
116
|
+
// Process is already running or in errored state - restart it
|
|
117
|
+
const { restartProcess } = await import('../../core/instance/pm2-bridge.js');
|
|
118
|
+
result = await restartProcess(botName);
|
|
119
|
+
} else {
|
|
120
|
+
// Process doesn't exist or is stopped - start it
|
|
121
|
+
result = await startProcess(scriptPath, botName, options);
|
|
122
|
+
}
|
|
111
123
|
|
|
112
124
|
if (!result.success) {
|
|
113
125
|
return reply.code(400).send({
|