appy-one / acebase-server

A fast, low memory, transactional, index & query enabled NoSQL database server for node.js that easily syncs with browser and node.js clients and servers
MIT License
32 stars 14 forks source link

Restart server #77

Closed srebling closed 1 year ago

srebling commented 1 year ago

What is the proper way to programmatically stop and restart acebase-server? After running the code below, what commands are necessary to shutdown the server before running the same code again?

`

    const { AceBaseServer } = require('acebase-server');
    const dbname = 'Messages';

    const settings = {
        path: './',
        host: 'localhost',
        port: 5757,
        authentication: {
            enabled: false,
            allowUserSignup: false,
            defaultAccessRule: 'allow',
            defaultAdminPassword: '75sdDSFg37w5'
        }
    }

    const server = new AceBaseServer(dbname, settings);
    server.on("ready", () => {
        console.log("SERVER ready");
    });

`

appy-one commented 1 year ago

First of all, my apologies for this late reply! Run server.shutdown()

From the JSDocs:

shutdown(): void Shuts down the server. Stops listening for incoming connections, breaks current connections and closes the database. Is automatically executed when a "SIGINT" process event is received.

Once the shutdown procedure is completed, it emits a "shutdown" event on the server instance, "acebase-server-shutdown" event on the process, and sends an 'acebase-server-shutdown' IPC message if Node.js clustering is used. These events can be handled by cluster managing code to kill or exit the process safely.

Do you like AceBase? 👇🏼

Sponsor AceBase Spread the word contribute