ume.close()

Note

You need version 1.3.0 or newer.

umejs currently does not spin up any extra processes by default. However, it does when you use parallel mode and/or development mode. These processes need to be properly closed when you stop your server. To do this, we need a very simple on close event. You may have seen this before in some other places in the documentation already.

It can be as simple as the following, but this is not the recommended version!

process.on('SIGINT', async () => {
    await umeConfig.close();
});

Why? Because it's quite unlikely that you're only using umejs. You're almost certainly using it in combination with Express and that's something to account for. Here's the full version, from start to finish:

// --- Import Express and umejs ---
const ume = require('@dantenl/umejs');
const express = require('express');
const path = require('path');

// --- Initialise Express ---
const app = express();
const PORT = 3000

// --- Initialise umejs ---
const umeConfig = ume({
    parallel: true,
    mode: "development",

    contentDir: path.join(__dirname, 'blog'),
    templatePath: path.join(__dirname, 'template', 'layout.ume.html')
});

// --- Set up the umejs middleware ---
app.use('/blog/{*slug}', umeConfig);

// --- Get the server running ---
const server = app.listen(PORT, () => {
    console.log(`Server running at http://localhost:${PORT}`);
});

// --- Fully close ume ---
process.on('SIGINT', async () => {
    server.close(); // close express
    await umeConfig.close(); // close umejs
    process.exit(0); // clean exit
});