File size: 708 Bytes
b39afbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
 * All rights reserved.
 */

import {omnilog} from 'omni-shared';

const script = {
  name: 'rs',
  description: 'Restarts the server',
  exec: async function (ctx, payload) {
    await ctx.app.sendMessageToSession(ctx.session.sessionId, 
      '⚠️ The server is restarting, please wait. ⚠️', 
      'text/plain');

    // Brief pause to allow message and result to be sent

    setTimeout(() => {
      omnilog.log('Forcing app restart...');
      // Invoke a restart by IPC - only works if launched from launcher.js
      process.send({cmd: 'restart'});
    }, 100);

    return {
      result: { ok: true }
    }    
  }
}

export default script