How to shutdown osjs remotely via websockets


Hi! I’m thinking of making a sort of dashboard to control your osjs instance. Is there a way to make osjs shutdown via a button press on this dashboard?

Eg. Press button and it sends kill signal via websockets to the OS


You can add an event listener on your server core instance to do this:

// server
core.on('shutdown-my-instance', () => core.destroy())

// client{
  name: 'shutdown-my-instance',
  params: [] // Must be defined


so would i link the server code to the os and the client code to the button? and i would like this to be remote like

  1. connect to instance via websocket address for osjs from external site
  2. send signal
  3. shutdown


Then you’re probably better off creating a basic HTTP endpoint on the OS.js server. By default you can’t connect to the websocket without having a session on the same domain.


okay, thanks!

issue has been solved