@@ -185,4 +185,69 @@ describe('PM2 MCP server', function () {
185185
186186 await callToolWithTimeout ( 'pm2_delete_process' , { process : name } ) ;
187187 } ) ;
188+
189+ it ( 'pm2_restart_process restarts a running process' , async ( ) => {
190+ const name = 'mcp-restart-test' ;
191+ await startEcho ( name ) ;
192+ await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
193+
194+ const restartRes = await callToolWithTimeout ( 'pm2_restart_process' , { process : name } ) ;
195+ should ( restartRes . isError ) . not . equal ( true ) ;
196+ should ( restartRes . structuredContent . action ) . eql ( 'restart' ) ;
197+ should ( restartRes . structuredContent . process ) . eql ( name ) ;
198+ should ( restartRes . structuredContent . processes ) . be . an . Array ( ) ;
199+
200+ await callToolWithTimeout ( 'pm2_delete_process' , { process : name } ) ;
201+ } ) ;
202+
203+ it ( 'pm2_reload_process reloads a running process' , async ( ) => {
204+ const name = 'mcp-reload-test' ;
205+ await startEcho ( name ) ;
206+ await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
207+
208+ const reloadRes = await callToolWithTimeout ( 'pm2_reload_process' , { process : name } ) ;
209+ should ( reloadRes . isError ) . not . equal ( true ) ;
210+ should ( reloadRes . structuredContent . action ) . eql ( 'reload' ) ;
211+ should ( reloadRes . structuredContent . process ) . eql ( name ) ;
212+ should ( reloadRes . structuredContent . processes ) . be . an . Array ( ) ;
213+
214+ await callToolWithTimeout ( 'pm2_delete_process' , { process : name } ) ;
215+ } ) ;
216+
217+ it ( 'pm2_flush_logs flushes log files for a process' , async ( ) => {
218+ const name = 'mcp-flush-test' ;
219+ await startEcho ( name ) ;
220+ await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
221+
222+ const flushRes = await callToolWithTimeout ( 'pm2_flush_logs' , { process : name } ) ;
223+ should ( flushRes . isError ) . not . equal ( true ) ;
224+ should ( flushRes . structuredContent . action ) . eql ( 'flush' ) ;
225+ should ( flushRes . structuredContent . process ) . eql ( name ) ;
226+
227+ await callToolWithTimeout ( 'pm2_delete_process' , { process : name } ) ;
228+ } ) ;
229+
230+ it ( 'pm2_reload_logs rotates and reopens log files' , async ( ) => {
231+ const name = 'mcp-reloadlogs-test' ;
232+ await startEcho ( name ) ;
233+ await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
234+
235+ const reloadLogsRes = await callToolWithTimeout ( 'pm2_reload_logs' ) ;
236+ should ( reloadLogsRes . isError ) . not . equal ( true ) ;
237+ should ( reloadLogsRes . structuredContent . action ) . eql ( 'reloadLogs' ) ;
238+
239+ await callToolWithTimeout ( 'pm2_delete_process' , { process : name } ) ;
240+ } ) ;
241+
242+ it ( 'pm2_dump persists the current process list' , async ( ) => {
243+ const name = 'mcp-dump-test' ;
244+ await startEcho ( name ) ;
245+ await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
246+
247+ const dumpRes = await callToolWithTimeout ( 'pm2_dump' ) ;
248+ should ( dumpRes . isError ) . not . equal ( true ) ;
249+ should ( dumpRes . structuredContent . action ) . eql ( 'dump' ) ;
250+
251+ await callToolWithTimeout ( 'pm2_delete_process' , { process : name } ) ;
252+ } ) ;
188253} ) ;
0 commit comments