Skip to content

Running Ioto

After building Ioto, the Ioto and other binaries and libraries will be in the bin directory.

You may want to add this directory to your shell PATH.

bash
export PATH=`pwd`/build/bin:$PATH

Or you can easily run Ioto via make run:

bash
$ make run
app: info: Starting Ioto 2.1.1, with "standard" app 1.0.0, using "dev" profile
setup: info: Enabling services: db provision register sync serialize test web
app: info: Device Claim ID: M72DANY8BZ
register: info: Device registered with https://api.admin.embedthis.com/api
{
    "product": "01H4R15D3478JD26YDYK408XE6",
    "id": "M72DANY8BZ",
    "created": "2024-01-23T02:03:57.062Z"
}
register: info: Device not yet claimed
web: info: Listening http://:9090
web: info: Listening https://:4443
app: info: Ioto 2.4.0 ready, Device firmware 1.3.0

When Ioto runs, it listens on any required HTTP ports (if you are running the web server service) and registers with the cloud. If your selected services enable the web server, Ioto will listen for connections on ports 80 for HTTP and 443 for HTTPS and serve documents from the ./site directory.

To manage your device from the cloud, read Managing from the Cloud.

Ioto Command Line

On Linux or Mac OS X, Ioto is installed by default in the directory /usr/local/lib/ioto. The Ioto binary program is installed at /usr/local/bin/ioto, and the Ioto configuration is at /etc/ioto.

The Ioto command line is:

bash
ioto [options]

Ioto Command Options

OptionDescription
--account IDManager account for self-claiming.
--backgroundRun Ioto in the background detached from the terminal.
--cloud TokenCloud claim token for self-claiming.
--config dirSet the directory for config files.
--configFilePath to the ioto.json5 configuration file.
--debugEmit very verbose debug tracing.
--exit event or secondsExit on event or after 'seconds'.
--home directoryChange to directory to run.
--id TokenDevice claim ID. Overrides device.json5.
--ioto pathSet the path for the ioto.json5 config.
--mode modeSelect execution mode from ioto.json5 (dev,prod).
--nolocalDo not apply local.json5.
--nosaveRun in-memory and do not save state.
--product TokenProduct claim ID. Overrides device.json5.
--profile profileSelect execution profile from ioto.json5
--quietDon't show web server headers. Alias for --show ''.
--resetReset state to factory defaults.
--show [HBhb]Show request headers/body (HB) and response headers/body (hb).
--state dirDirectory for the state files.
--test SuiteRun test suite from config/test.json5.
--timeoutsDisable timeouts for debugging.
--trace file[:types:from]Trace to file.
--verboseVerbose operation. Alias for --show Hhb plus module trace.
--versionOutput version information

When Ioto starts, it reads the ioto.json5 and other configuration files from the Ioto config directory. These are copied at build-time from the apps/NAME/config directory. The ioto.json5 file defines the default logging and tracing configuration. This can be overridden by command line options and environment variables. See below for details.

See Configuration Files for details.

Logging and Tracing

Ioto provides detailed log tracing for all operational aspects of Ioto.

The Ioto tracing is configured via the log property collection in the ioto.json5 file.

The log property specifies the trace destination via the path property. This property can be set to stdout, stderr, or any filename or cloud to send log files to AWS cloudwatch.

js
log: {
    path: 'ioto.log',
    format: '%D %H %A[%P] %T %S %M',
    types: 'error,info',
    sources: 'all',
},

The format property specifies how the log messages will be formatted. It contains a printf style string with tokens that are expanded at runtime. The supported tokens are: 'A' for the application name, 'D' for the local datetime, 'H' for the system hostname, 'M' for the trace message, 'P' for the process ID , 'S' for the message source, and 'T' for the trace message type.

Message Types

Ioto classifies trace messages according to types. The supported types are: debug, error, fatal, info, and trace. The types property specifies a comma separate list of trace message types to emit.

Message Sources

Log messages are emitted from "sources". These are the names of the code module that originate the trace messages. The sources property is a comma separated list of sources. Some of the Ioto trace message sources are: "runtime", "tls", "json", "url" and "web".

You can use "all" for types and sources to match all types/sources. You can also use "!type" and "!source" to negate a type or source.

For example:

js
types: 'all,!debug,!trace'

This will emit messages of all types, except for debug and trace messages.

Command Line

The logging configuration defined in the ioto.json5 file can be overridden via via the --trace, --verbose and --debug Ioto command line options. It can also be overridden via the LOG_FILTER environment variable.

The --trace option specifies the trace file destination and a list of types and sources.

bash
$ ioto --trace FILENAME[:TYPES[:SOURCES]]

The types are a comma separated list of message types. Valid types include: info, debug, error, trace and all. Sources are the code module names originating the trace messages. You can use "!type" and "!source" to negate a type or source.

For example:

bash
$ ioto --trace trace.log  # Same as path:trace.log   
$ ioto --verbose          # Same as path:stdout, types:raw,error,info, sources:all
$ ioto --debug            # Same as path:stdout, types:raw,error,info,trace,!debug, sources:all
$ ioto --trace file:all:all 
$ ioto --trace file:all,!debug,!trace:all

You can also use the -v short cut for --verbose and -d for --debug.

Trace Environment Overrides

Similar to the command line options, you can override the trace configuration via two environment varables.

Command Line OptionsEnvironment VariableDescription
--traceLOG_FILTEROverride the log filter definition
--verboseOverride the log filter definition
--debugOverride the log filter definition

These variables take the same string values as their command line option counterparts.

The order of precedence of configuration is:

  1. Command line --trace, --debug or --verbose options
  2. Environment variable LOG_FILTER, LOG_FORMAT values
  3. ioto.json5 configuration

Web Server Tracing

Ioto provides special control for the web server HTTP request and response tracing. You can selectively trace HTTP request and response headers and bodies via the show property.

js
log: {
    show: 'hB',
    path: 'ioto.log',
    format: '%D %H %A[%P] %T %S %M',
    types: 'error,info',
    sources: 'all',
},

The show property is a string with the following characters:

CharacterDescription
bShow the response body
hShow the response HTTP headers
BShow the client request HTTP body
HShow the client request HTTP headers
emptyShow no HTTP trace

You can override the ioto.json5 show property configuration via the --show Ioto command line option.

For example:

bash
$ ioto --show hH

You can also override the configuration via the WEB_SHOW environment variable.

Command Line OptionsEnvironment VariableDescription
--showWEB_SHOWOverride the show definition

The order of precedence of configuration is:

  1. Command line --show option value
  2. Environment variable LOG_FILTER, LOG_FORMAT values
  3. ioto.json5 configuration

HTTP Client Tracing

Similar to the web server HTTP tracing, you can trace client HTTP requests and responses. Tracing HTTP client requests can be enabled via the URL_SHOW environment variable.

For example:

bash
$ URL_SHOW=hH ioto --trace trace.log

This will trace any client HTTP requests issued via the URL module. This includes internal Ioto client requests and your own client HTTP requests that use the URL API.

Other Environment Varialbes

You can override the Ioto mode and profile settings via environment variables:

Command Line OptionEnvironment VariableDescription
--mode MODEIOTO_MODEOverride the execution mode (cloud | local)
--profile PROFILEIOTO_PROFILEOverride the execution profile (dev | prod)

Test Suites

Ioto provides a test facility via the Unit testing app. The apps/unit/test.json5 configuration file defines the available test suites. You can create your own tests in the unitTest.c source file and define them in the test.json5 config file.

The default Ioto source distribution includes a demo property collection to run a simple demo test that will increment a counter and post to the device database.

js
demo: {
    count: 30,
    delay: '30sec',
    enable: true,
    type: 'sync',
},

The count property defines how many test iterations will be performed. The delay property indicates the delay between each test. The type property selects the type of test.

Ioto Manual Pages

This Ioto distribution provides manual pages that can be viewed (on Unix-like systems) using the systems man command. Text copies of the pages are included below:

TopicDescription
iotoIoto device agent
dbDatabase client program
passPassword manager
urlURL HTTP client test program