diff --git a/server/src/app.ts b/server/src/app.ts index 8986650..d6073f0 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -52,6 +52,7 @@ AppDataSource.initialize() await MatterbridgeManager.spawnAll(); console.log('Spawned group processes:'); - console.log(MatterbridgeManager.processes); + let proclist = await MatterbridgeManager.processes; + console.log(proclist); }) diff --git a/server/src/matterbridge/process.ts b/server/src/matterbridge/process.ts index f3ed67c..31fe819 100644 --- a/server/src/matterbridge/process.ts +++ b/server/src/matterbridge/process.ts @@ -79,11 +79,11 @@ class MatterbridgeManager { ) } - get processes(): Process[] { - let processes: Process[] = [] - pm2.list() - .then((err:any, list:[]) => { - processes = list.map((proc:any) => { + get processes(): Promise { + return new Promise((resolve, reject) => { + pm2.list((err:any, list:[]) => { + if (err) reject(err); + else resolve(list.map((proc:any) => { return { name: proc.name, pid: proc.pid, @@ -100,9 +100,8 @@ class MatterbridgeManager { pm_pid_path: proc.pm2_env.pm_pid_path, } } - }) - }) - return processes + })) + })}) } }