PrismarineJS / flying-squid

Create Minecraft servers with a powerful, stable, and high level JavaScript API.

Home Page:https://prismarinejs.github.io/flying-squid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stop a server?

CriminosaMC opened this issue · comments

I have scoured the documentation for a little while and I don't see any "elegant" way of stopping the server. How do I stop the server? I have the Server instance stored in a variable, and after x amount of time I want to stop the server.

I've found a temporary workaround for the time being. It doesn't appear to be that elegant, but I looked through the source and discovered the close method in the node-minecraft-protocol package that this package utilises for servers.

Example code:

const mcServer = require("flying-squid");
const server = mcServer.createMCServer({
// options...
});

setTimeout(() => {
    server._server.close();
}, 300000);

serv.quit('Server closed')
process.exit()