Giter Site home page Giter Site logo

putrick / dinman Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kihenkel/dinman

0.0 0.0 0.0 93 KB

dinman stands for dependency-instance-manager. A Node.js application that manages other Node.js applications on-demand on a dependency basis.

JavaScript 100.00%

dinman's Introduction

dinman

dinman stands for dependency-instance-manager. A Node.js application that manages other Node.js applications on-demand on a dependency basis.

This application is based on node-instance-manager.

Requirements

Requires Node 8.x or higher.

What is it for?

If you're using multiple Node.js at the same time and trying to set them up on your local machine, then dinman might be suitable for you. It not only lets you start/stop those apps within one shell, it also knows about dependencies between those apps and fires up all required apps with one command.

Startup

First you need to build a config to let dinman know about the apps and their dependencies:

npm run buildconfig -- "C:\code\my-apps" "C:\code\my-services"

You can pass as many paths as you wish. Note that those paths have to point to the parent directory of your Node applications. Then it'll crawl through all sub-directories.

The log output should give you hints if it worked as intended. In the end you should have a generated config.json in your root folder. Now start dinman via npm start or node .\index.js and use the available commands. (type help)

Shell commands

The node-instance-manager provides a shell with the following commands:

  • ls - Lists all apps from config
  • start [app] - Starts an app with dependencies
  • start-excluded [app] - Starts apps dependencies but not app itself
  • start-only [app] - Starts app only (without dependencies)
  • start-all - Starts all apps from config
  • restart [app] - Restarts an app
  • stop [app] - Stops an app
  • stop-all - Stops all running apps
  • log [app] - Outputs the log for an app
  • rebuild - Rebuilds dinman config (based on initally provided paths)
  • cmd [app] [command] - Executes command in app working dir (EXPERIMENTAL! Use at own risk.)
  • cmd-all [command] - Executes command for all apps in their working dirs (EXPERIMENTAL! Use at own risk.)

Misc

How it works

There's no generally applicable way of determining dependencies between Node.js apps. Therefore dinman looks for certain patterns. It assumes the following:

  • A package.json file exists and contains information about name, port and preferably entry of the application
  • The config package is used and a config/default.json file is present
  • The default.json file contains links to other applications via localhost:port or 127.0.0.1:port

While building the config, if default.json contains a port mapping to one of the detected apps then a dependency is concluded.

Application type

The config builder automatically determines an application's type. Right now the pattern is very simple:

Assuming that the app name is built with dashes, it takes the very last part. (or to say it in regex: /([^-]+)$/) Eg. my-cool-service will resolve to type service, that-awesome-application will resolve to type application.

Loose dependencies

Sometimes even though there is a dependency from one application to another, you don't want it to start automatically (eg. dependency from a backend service to a frontend website). You can configure this as a loose dependency for dinman, based on the applications type. (refer to Application type for determining the type) To do so, add a dependencyConfig.json to your root folder:

dependencyConfig.json

{
  "looseDependencyTypes": [
    { "from": "service", "to": "app" },
    { "from": "app", "to": "app" }
  ]
}

This configures eg. the type app to be a loose dependency to service. If now a service has a dependency to an app, the app will not start automatically.

dinman's People

Contributors

kihenkel avatar putrick avatar patricheck24 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.