magicbin
TypeScript icon, indicating that this package has built-in type declarations

1.4.2 • Public • Published

magicbin

Simple process manager; alternative to pm2

Installation

yarn add magicbin

Usage

  1. Create a magicbin.config.js file. Take example on the demo one.
  2. After each change, run yarn mb sync to apply the new configuration.
  3. If you wish to access the logs, run yarn mb open.
  4. To stop the local namespace, run yarn mb stop.
  5. To fully stop the daemon itself, run yarn mb daemon stop.

Advanced

Daemon debug

For magicbin development or debug purposes, you can spawn its daemon as a regular process by running the following in a tab:

DEBUG='mb:*' CLIPANION_DAEMON=1 yarn mb

You'll then be able to run any command as usual from other terminals, which will execute inside the daemon you've spawned.

Inter-process requirements

You can force a process to only start once another has started (and has been confirmed, if relevant, cf next section). To do that, just add a dependsOn field to your task definition.

Process confirmation

Magicbin supports a non-standard protocol that lets processes notify the daemon that they have properly been setup. This is a good match for many kind of servers, which need to asynchronously go through various steps before being truly initialized.

To leverage that, the easiest way is to use the Magicbin Node API:

import {confirmProcess} from 'magicbin';

const server = http.createServer((req, res) => {
  res.end();
});

setTimeout(() => {
  server.listen(4500, () => {
    console.log(`Started to listen`);
    confirmProcess();
  });
}, 5000);

License (MIT)

Copyright © 2021 Mael Nison

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i magicbin

Weekly Downloads

1

Version

1.4.2

License

MIT

Unpacked Size

1.45 MB

Total Files

123

Last publish

Collaborators

  • arcanis