Socket
Socket
Sign inDemoInstall

@flamescape/k8s-app

Package Overview
Dependencies
22
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @flamescape/k8s-app

A wrapper for Kubernetes app deployment


Version published
Weekly downloads
1
Maintainers
1
Install size
872 kB
Created
Weekly downloads
 

Readme

Source

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();

FAQs

Last updated on 21 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc