0.0.9 • Published 2 years ago

@flamescape/k8s-app v0.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

A wrapper for Kubernetes app deployment

See sample k8s and skaffold yamls in samples/, and refer to example usage below.

Example Usage

const App = require('@flamescape/k8s-app');

App({configPath: process.env.CONFIG_PATH || './conf/dev.yaml'})
    .onStartup(async function({config, locals, exitHandler}) {
        // create database connection pool
        locals.db = await mysql.createPool(config.database);
        locals.db.on('error', exitHandler); // errors re-route to the exitHandler for graceful shutdown

        // create express webserver
        locals.app = express();
        const port = process.env.PORT || 80;
        locals.httpServer = locals.app.listen(port);

        console.log('Started');
    })
    .onShutdown(async function({config, locals, error}) {
        // close & dispose of resources in reverse order
        if (locals.httpServer) {
            console.log('Closing web service');
            locals.httpServer.close();
        }
        if (locals.db) {
            console.log('Closing DB connection');
            await locals.db.end();
        }
        console.log('Done');
    })
    .onProbe(async function({config, locals, probeType}){
        // probe callback should always throw on failure.
        await locals.db.query('SELECT 1');
    })
    .run();
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago