DEV Community

Cover image for No need to open 4 tabs in your terminal for your projects!
Médéric Burlet for Pixium Digital

Posted on

No need to open 4 tabs in your terminal for your projects!

Very often when working on full stack solutions we find ourselves opening 4+ tabs in our terminal. We would run a yarn dev for on micro-service then a yarn start for react and so on.

This has always been annoying to handle and so we built Child Manager which lets you manager child processes for your project from just a simple config file.

https://github.com/pixiumdigital/child-manager/

Installation

To install run the following commands:

yarn add @pixium-digital/child-manager
Enter fullscreen mode Exit fullscreen mode

You can also use NPM

npm install @pixium-digital/child-manager
Enter fullscreen mode Exit fullscreen mode

Run

To leverage child manager simply add a configuration file to your project (see below for config details)

You can run thew following command:

yarn child-manager
Enter fullscreen mode Exit fullscreen mode

By default the loaded config will be at the source of the project and be named childmanager.json

If you wish to load a different file just pass the config option.

yarn child-manager --config="./myconfig.json"
Enter fullscreen mode Exit fullscreen mode

You can then access the manager at the following:

http://localhost:7000

Configuration

Here is an example configuration

{
  "processes": [
    {
      "name": "Test Service",
      "command": {
        "executor": "node",
        "args": ["TestService.js"],
        "path": "./src/service",
        "isWindows": false
      },
      "maxLogs": 200
    },
    {
      "name": "Service 2",
      "command": {
        "executor": "yarn",
        "args": ["start"],
        "path": "./other-project/service",
        "isWindows": false
      },
      "maxLogs": 200
    }
  ],
  "captureExit": true,
  "longLive": false,
  "debug": false
}
Enter fullscreen mode Exit fullscreen mode

Generic configurations:

  • debug: This will show more logs in the terminal in case something is not working
  • longLive: This is to force process to stay alive. Use carefully.
  • captureExit: This binds the exit of child manager so that it will kill all childs

Process configurations:

  • name: The name of your service
  • maxLogs: The max number of logs to keep in memory (recommended 200)

  • command: This houses the command line that will be launched

    • executor: The command executor (yarn, npm, node)
    • args: Array or extra arguments that should be passed
    • path: Where the command should be executed
    • isWindows: Is this running on windows system? if yes paths and executors will be automatically changed to be compatible

Conclusion

With the use of one simple configuration file we are now able to launch all our mini services efficiently and with ease regardless of the fact that it might be a yarn script a npm script or even a command line

If you wish to contribute feel free to check out the code:

https://github.com/pixiumdigital/child-manager/


About Us

Pixium Digital

https://pixiumdigital.com

https://github.com/pixiumdigital

Top comments (2)

Collapse
 
killshot13 profile image
Michael R.

Wow! Assuming it works as advertised, this is pretty awesome. Will definitely be trying this out! 👏

Collapse
 
crimsonmed profile image
Médéric Burlet

If you do encounter any issues feel free to open an issue. We are using it on a few projects as usually we have the following to run

  • Backend (node)
  • Frontend (react)
  • Rendering of status (node)
  • Rendering of svg assets (node)

I really got tired of every time opening 4 tabs + one for docker hahaha