Configuration
Cylon.JS supports configuration of internal settings via the Cylon#setConfig
method.
This method takes a JavaScript object as an argument, and merges it with Cylon's internal configuration.
For example:
var Cylon = require('cylon'); Cylon.config({ option: 'value' }); // rest of program
Additionally, if you'd like to fetch configuration details for use in your own application, Cylon#config will always return the current configuration:
var Cylon = require('cylon'); var config = Cylon.config({ option: 'value' }); config.option //=> 'value'
Read on for more details on the configuration options Cylon recognizes.
Mode
Cylon can be run in 'auto' mode, which means that robots will start by default when initialized.
Cylon.config({ mode: 'auto' }); // this bot will be automatically started Cylon.robot({ connections: { loopback: { adaptor: 'loopback' } }, devices: { ping: { driver: 'ping' } } });
API
The Cylon.js API plugin system allows for configuration:
In your scripts, you can set it up as so:
// instantiate, configure the HTTP API plugin Cylon.api("http", { host: '127.0.0.1', port: '4321', ssl: { cert: '/path/to/ssl/cert', key: '/path/to/ssl/key' }, auth: { type: 'basic', user: 'admin', pass: 'pass' } });
If you run a Cylon script with this code in it, it will start a HTTP API server listening on https://127.0.0.1:4321
, that will require basic auth for all routes.
Halt Timeout
When Cylon is told to shutdown, either via Cylon#halt
or Ctrl-C, it tries to gracefully shut down all Robots/Devices/Connections.
If this isn't possible inside of the specified haltTimeout
, Cylon will instead forcefully shut itself down.
Cylon.config({ haltTimeout: 4000 // time in milliseconds before forcefully shutting down });
This value defaults to three seconds (3000 ms).