Skip to content

Latest commit

 

History

History
99 lines (78 loc) · 2.73 KB

launcher.md

File metadata and controls

99 lines (78 loc) · 2.73 KB

Launcher

They are used to start one daemon by business messaging desired.

It's the starting point of the application!

Loading

The launcher are started with the loader script during the main startup process.

They can be loaded from the global configuration file config.json or by the individual configuration file launcher.json.

The first check is to know if the launcher is activate or not and depending of the global, specific or default configuration the launcher is started or not.

Execution

During the first execution steps, we can see in the log or the console the Controller loaded.

After the start the launcher are autonomous and don't need specific attention.

Organization

They are define in dedicated folder and they need at least the following files:

  • Module name
    • run.js: Scripts with the launcher code
    • conf.json: Default configuration file of the launcher

They are located in the './module' folder.

The JSON configuration file associate define the default configuration of the launcher and its standard parameters plus the default behaviors. This can be overloaded or completed by the global settings (config.json). It also follow the folder structure and so the launcher chain/path and its declaration.

Editors' url to get doc & token

Example

run.jss

// Load tools library
let Log = require(__basedir + 'lib/log');

// Load Botkit library
var Botkit = require(__basedir + 'botkit/lib/Botkit.js');

// Execute the main function
exports.run = function(config) {
  let controller = Botkit.web({
    debug: config.log.debug,
    studio_token: config.controller.on.botkit.token
  });

  let bot = controller.spawn({
    token: config.web.token
  }).startRTM();


  // Scenario declarations
  let scenario = require(__basedir + 'lib/controller.js');
  controller = scenario.run(controller);
  return controller;
};

conf.json

{
    "launcher": {
        "MyLauncher": {
            "enable": true,
            "name": "corebot-framework",
            "msg": {
                "help": [
                    "MyLauncher help"
                ]
            }
        }
    }
}