Skip to content

hourctl: listeners, endpoints, sinks and routes

Set up where devices connect (listeners), which package reads them (endpoints), where their events go (sinks), and where people’s punches go (routes), and route the punches that go nowhere yet.

Every hourctl command also takes the connection options.

hourctl listeners

List the listeners and whether each is running.

Prints each listener’s id, type (http or mqtt), address, state on the instance that answered (running, stopped, or the error that keeps it from running) and the endpoints on it.

hourctl listeners [OPTIONS]

Example:

Terminal window
hourctl listeners

hourctl listener

Add, change, remove, stop or start a listener.

A listener is where devices connect: an HTTP address the gateway listens on, or an MQTT broker it subscribes to. Every instance takes the change.

hourctl listener [OPTIONS] <COMMAND>

Commands:

  • add: Add a listener: —http IP:PORT or —mqtt URL.
  • set: Change a listener: only the options given change.
  • remove: Remove a listener.
  • stop: Stop a listener.
  • start: Start a stopped listener.

hourctl listener add

Add a listener: —http IP:PORT or —mqtt URL.

Address lists (allow_from, deny_from) and the PROXY protocol are set with hourctl apply.

hourctl listener add [OPTIONS] <ID>

Arguments:

  • <ID>: The new listener’s id, e.g. public.

Options:

  • --http <IP:PORT>: An HTTP listener on this address (IP:PORT), e.g. 0.0.0.0:8080.
  • --mqtt <URL>: An MQTT listener on this broker: mqtt://host:1883, or mqtts://host:8883 for TLS.
  • --username <NAME>: MQTT: the user name to log in to the broker with.
  • --broker-password <PASSWORD>: MQTT: the broker password. It is kept in the database and never shown. On the command line it shows in the shell’s history; a setup file’s password_env (hourctl apply) keeps it off.
  • --window <MESSAGES>: MQTT, required for a new listener: how many unacknowledged messages the broker gives a client at once (its in-flight window: Mosquitto’s max_inflight_messages, 20 unless set). The listener holds no more.

Examples:

Terminal window
hourctl listener add public --http 0.0.0.0:8080
hourctl listener add broker --mqtt mqtts://broker.example.com:8883 --username houradvantage

hourctl listener set

Change a listener: only the options given change.

hourctl listener set [OPTIONS] <ID>

Arguments:

  • <ID>: The listener’s id.

Options:

  • --http <IP:PORT>: An HTTP listener on this address (IP:PORT), e.g. 0.0.0.0:8080.
  • --mqtt <URL>: An MQTT listener on this broker: mqtt://host:1883, or mqtts://host:8883 for TLS.
  • --username <NAME>: MQTT: the user name to log in to the broker with.
  • --broker-password <PASSWORD>: MQTT: the broker password. It is kept in the database and never shown. On the command line it shows in the shell’s history; a setup file’s password_env (hourctl apply) keeps it off.
  • --window <MESSAGES>: MQTT, required for a new listener: how many unacknowledged messages the broker gives a client at once (its in-flight window: Mosquitto’s max_inflight_messages, 20 unless set). The listener holds no more.

Example:

Terminal window
hourctl listener set public --http 0.0.0.0:8081

hourctl listener remove

Remove a listener. Refused while an endpoint uses it.

hourctl listener remove [OPTIONS] <ID>

Arguments:

  • <ID>: The listener’s id.

Example:

Terminal window
hourctl listener remove public

hourctl listener stop

Stop a listener. It stays stopped, across restarts too, until started.

hourctl listener stop [OPTIONS] <ID>

Arguments:

  • <ID>: The listener’s id.

Example:

Terminal window
hourctl listener stop public

hourctl listener start

Start a stopped listener.

hourctl listener start [OPTIONS] <ID>

Arguments:

  • <ID>: The listener’s id.

Example:

Terminal window
hourctl listener start public

hourctl endpoints

List the endpoints: where on a listener each one is, its package and sinks.

Prints each endpoint’s id, listener, path or topic (“(whole port)” for an HTTP endpoint without a path), package, delivery, sinks and state: running, stopped, or why the instance that answered does not serve it.

hourctl endpoints [OPTIONS]

Example:

Terminal window
hourctl endpoints

hourctl endpoint

Add, change, remove, stop or start an endpoint.

An endpoint is a path (HTTP) or topic (MQTT) on a listener: the devices that reach it are read by one package, and their events go to the endpoint’s sinks.

hourctl endpoint [OPTIONS] <COMMAND>

Commands:

  • show: Show one endpoint: its package, listener, path or topic, state, sinks, sync group, options and labels.
  • add: Add an endpoint: —listener and —package are required.
  • set: Change an endpoint: only the options given change.
  • remove: Remove an endpoint.
  • stop: Stop an endpoint: its devices are answered 503 until it is started.
  • start: Start a stopped endpoint.

hourctl endpoint show

Show one endpoint: its package, listener, path or topic, state, sinks, sync group, options and labels.

hourctl endpoint show [OPTIONS] <ID>

Arguments:

  • <ID>: The endpoint’s id.

Example:

Terminal window
hourctl endpoint show office

hourctl endpoint add

Add an endpoint: —listener and —package are required.

Address lists (allow_from, deny_from) are set with hourctl apply.

hourctl endpoint add [OPTIONS] <ID>

Arguments:

  • <ID>: The new endpoint’s id, e.g. office.

Options:

  • --listener <LISTENER>: The listener the endpoint is on (its id), e.g. public.
  • --package <PACKAGE>: The package that reads its devices: a name, or a name pinned to a version prefix, e.g. zk-push or [email protected].
  • --path <PATH>: HTTP: the path prefix it claims, e.g. /office or /site/{site}. Without one, it claims the whole listener.
  • --topic <TOPIC>: MQTT: the topic devices publish to, e.g. clocks/{device}/events.
  • --reply-topic <TOPIC>: MQTT: the topic for replies and commands, e.g. clocks/{device}/commands. It may use the topic’s placeholders.
  • --sink <SINK>...: A sink that is sent the endpoint’s events (its id); repeat for several. With set, the list replaces the endpoint’s sinks.
  • --no-sinks: Send the endpoint’s events to no sink. They are still stored, and hourctl events reads them.
  • --new-devices <WHAT>: What becomes of a device nobody has registered. Default for a new endpoint: hold. One of: allow (It registers itself and is let in), hold (It registers itself, and is refused until someone allows it), refuse (It is turned away, and no record of it is kept).
  • --sync-group <GROUP>: The sync group the endpoint’s allowed devices are members of (its id), e.g. hq.
  • --no-sync-group: Take the endpoint out of its sync group. Nothing is deleted from its devices.
  • --option <KEY=VALUE>...: An option handed to the package as ctx.options, KEY=VALUE; repeat for several. A number or true/false is sent as one, anything else as text. With set, these are added to the endpoint’s options, and KEY= takes one away.
  • --label <KEY=VALUE>...: A label every device of the endpoint has, KEY=VALUE (what a sync group’s placement rules pick members by); repeat for several. With set, these are added to the endpoint’s labels, and KEY= takes one away.

Example:

Terminal window
hourctl endpoint add office --listener public --package zk-push --path /office --sink payroll

hourctl endpoint set

Change an endpoint: only the options given change.

—sink replaces the endpoint’s sinks; —option and —label add to or change its options and labels, and KEY= takes one away.

hourctl endpoint set [OPTIONS] <ID>

Arguments:

  • <ID>: The endpoint’s id.

Options:

  • --listener <LISTENER>: The listener the endpoint is on (its id), e.g. public.
  • --package <PACKAGE>: The package that reads its devices: a name, or a name pinned to a version prefix, e.g. zk-push or [email protected].
  • --path <PATH>: HTTP: the path prefix it claims, e.g. /office or /site/{site}. Without one, it claims the whole listener.
  • --topic <TOPIC>: MQTT: the topic devices publish to, e.g. clocks/{device}/events.
  • --reply-topic <TOPIC>: MQTT: the topic for replies and commands, e.g. clocks/{device}/commands. It may use the topic’s placeholders.
  • --sink <SINK>...: A sink that is sent the endpoint’s events (its id); repeat for several. With set, the list replaces the endpoint’s sinks.
  • --no-sinks: Send the endpoint’s events to no sink. They are still stored, and hourctl events reads them.
  • --new-devices <WHAT>: What becomes of a device nobody has registered. Default for a new endpoint: hold. One of: allow (It registers itself and is let in), hold (It registers itself, and is refused until someone allows it), refuse (It is turned away, and no record of it is kept).
  • --sync-group <GROUP>: The sync group the endpoint’s allowed devices are members of (its id), e.g. hq.
  • --no-sync-group: Take the endpoint out of its sync group. Nothing is deleted from its devices.
  • --option <KEY=VALUE>...: An option handed to the package as ctx.options, KEY=VALUE; repeat for several. A number or true/false is sent as one, anything else as text. With set, these are added to the endpoint’s options, and KEY= takes one away.
  • --label <KEY=VALUE>...: A label every device of the endpoint has, KEY=VALUE (what a sync group’s placement rules pick members by); repeat for several. With set, these are added to the endpoint’s labels, and KEY= takes one away.

Example:

Terminal window
hourctl endpoint set office --new-devices allow --label site=north

hourctl endpoint remove

Remove an endpoint.

hourctl endpoint remove [OPTIONS] <ID>

Arguments:

  • <ID>: The endpoint’s id.

Example:

Terminal window
hourctl endpoint remove office

hourctl endpoint stop

Stop an endpoint: its devices are answered 503 until it is started.

hourctl endpoint stop [OPTIONS] <ID>

Arguments:

  • <ID>: The endpoint’s id.

Example:

Terminal window
hourctl endpoint stop office

hourctl endpoint start

Start a stopped endpoint.

hourctl endpoint start [OPTIONS] <ID>

Arguments:

  • <ID>: The endpoint’s id.

Example:

Terminal window
hourctl endpoint start office

hourctl sinks

List the sinks and what is waiting for each.

Prints each sink’s id, URL, the event types it takes (“default” when it names none: the default set), whether its requests are signed, how many events wait for it (with + when there are more than the gateway counts), and its state: ok, or failing since when and why. With —json it prints {"sinks": [...], "status": [...]}.

hourctl sinks [OPTIONS]

Example:

Terminal window
hourctl sinks

hourctl sink

Add, change, move or remove a sink.

A sink is a webhook the gateway POSTs events to, as JSON ({"events": [...]}), in order and until it answers 2xx.

hourctl sink [OPTIONS] <COMMAND>

Commands:

  • add: Add a sink: a webhook (—url), or a receiver in the program (—receiver).
  • set: Change a sink: only the options given change.
  • remove: Remove a sink.
  • position: Move a sink along the stored events.

hourctl sink add

Add a sink: a webhook (—url), or a receiver in the program (—receiver).

hourctl sink add [OPTIONS] <ID>

Arguments:

  • <ID>: The new sink’s id, e.g. payroll.

Options:

  • --url <URL>: The URL events are POSTed to, e.g. https://payroll.example.com/houradvantage.
  • --secret <SECRET>: A secret to sign requests with: each carries x-houradvantage-timestamp and x-houradvantage-signature, v1= and the hex HMAC-SHA256 of the timestamp, a full stop and the body. For an in_process sink, the key the receiver checks: for the attendance receiver, a delivery key the Time and Attendance tenant issued (hourctl -t ID attend delivery-keys create). Kept in the database and never shown. @FILE reads it from a file; a secret on the command line is in the process list and the shell’s history (see —secret-env).
  • --secret-env <VAR>: The environment variable that holds the secret (instead of —secret).
  • --event <TYPE>...: Only send events of this type, e.g. punch; repeat for several. Without it a new sink takes the default set: every type but the detailed ones sent only when named (see Events). With set, the list replaces the sink’s.
  • --default-events: Send the default set: clears the sink’s list of event types.
  • --system <SYSTEM>: The system the sink speaks for, e.g. attendance: it is sent the punches routed to it (to —receiver-tenant in it, when given), and each event about a person carries person_id, their id in it.
  • --receiver <RECEIVER>: Give the events to a receiver in the program instead of posting them (an in_process sink), e.g. attendance.
  • --receiver-tenant <ID>: The receiving system’s tenant the events are for: for the attendance receiver, a Time and Attendance tenant’s id (which every such sink names); with —system, the tenant in that system whose punches the sink is sent. Not the Connect tenant the sink belongs to (—tenant).
  • --source <SOURCE>...: Also send it the events the system SOURCE posts into its tenant (POST .../events), e.g. hr; repeat for several. An install-level Connect sink names attendance to be sent the events of that source in Connect’s log. With set, the list replaces the sink’s.
  • --match <FIELD=VALUE>...: Only send events whose data field has this value, FIELD=VALUE, e.g. exception=missing_out; repeat for several values or fields. With set, the list replaces the sink’s.
  • --latest-only <TYPE>...: Of the events of this type waiting about the same subject, only send the latest, e.g. device.options; repeat for several.
  • --max-per-second <MAX_PER_SECOND>: Send at most this many events a second.
  • --batch <BATCH>: Send at most this many events in one delivery.
  • --batch-bytes <BATCH_BYTES>: Send at most this many bytes of event data in one delivery.

Examples:

Terminal window
hourctl sink add payroll --url https://payroll.example.com/houradvantage --event punch
hourctl sink add time --receiver attendance --receiver-tenant acme --secret-env DELIVERY_KEY --event punch
hourctl sink add payroll --url https://payroll.example.com/in --secret @payroll-secret.txt

hourctl sink set

Change a sink: only the options given change.

hourctl sink set [OPTIONS] <ID>

Arguments:

  • <ID>: The sink’s id.

Options:

  • --url <URL>: The URL events are POSTed to, e.g. https://payroll.example.com/houradvantage.
  • --secret <SECRET>: A secret to sign requests with: each carries x-houradvantage-timestamp and x-houradvantage-signature, v1= and the hex HMAC-SHA256 of the timestamp, a full stop and the body. For an in_process sink, the key the receiver checks: for the attendance receiver, a delivery key the Time and Attendance tenant issued (hourctl -t ID attend delivery-keys create). Kept in the database and never shown. @FILE reads it from a file; a secret on the command line is in the process list and the shell’s history (see —secret-env).
  • --secret-env <VAR>: The environment variable that holds the secret (instead of —secret).
  • --event <TYPE>...: Only send events of this type, e.g. punch; repeat for several. Without it a new sink takes the default set: every type but the detailed ones sent only when named (see Events). With set, the list replaces the sink’s.
  • --default-events: Send the default set: clears the sink’s list of event types.
  • --system <SYSTEM>: The system the sink speaks for, e.g. attendance: it is sent the punches routed to it (to —receiver-tenant in it, when given), and each event about a person carries person_id, their id in it.
  • --receiver <RECEIVER>: Give the events to a receiver in the program instead of posting them (an in_process sink), e.g. attendance.
  • --receiver-tenant <ID>: The receiving system’s tenant the events are for: for the attendance receiver, a Time and Attendance tenant’s id (which every such sink names); with —system, the tenant in that system whose punches the sink is sent. Not the Connect tenant the sink belongs to (—tenant).
  • --source <SOURCE>...: Also send it the events the system SOURCE posts into its tenant (POST .../events), e.g. hr; repeat for several. An install-level Connect sink names attendance to be sent the events of that source in Connect’s log. With set, the list replaces the sink’s.
  • --match <FIELD=VALUE>...: Only send events whose data field has this value, FIELD=VALUE, e.g. exception=missing_out; repeat for several values or fields. With set, the list replaces the sink’s.
  • --latest-only <TYPE>...: Of the events of this type waiting about the same subject, only send the latest, e.g. device.options; repeat for several.
  • --max-per-second <MAX_PER_SECOND>: Send at most this many events a second.
  • --batch <BATCH>: Send at most this many events in one delivery.
  • --batch-bytes <BATCH_BYTES>: Send at most this many bytes of event data in one delivery.

Example:

Terminal window
hourctl sink set payroll --default-events

hourctl sink remove

Remove a sink. Refused while an endpoint or a sync group sends to it.

hourctl sink remove [OPTIONS] <ID>

Arguments:

  • <ID>: The sink’s id.

Example:

Terminal window
hourctl sink remove payroll

hourctl sink position

Move a sink along the stored events.

latest skips every event it has not taken. A sequence number N makes the events after N the next it is sent: lower than where it is sends events again. Prints where it was and where it is now.

hourctl sink position [OPTIONS] <ID> <SEQ|latest>

Arguments:

  • <ID>: The sink’s id.
  • <SEQ|latest>: A sequence number, or latest.

Example:

Terminal window
hourctl sink position payroll latest

hourctl route

List, add or remove routes: where punches can go.

A route names a receiving system, a tenant in it, and the person’s id there, with optional codes. Default routes are an endpoint’s or a sync group’s (an endpoint’s replace its group’s to the same system); a person’s own replace the defaults to the same system. A punch with exactly one route goes there; with several, the endpoint’s policy decides.

hourctl route [OPTIONS] <COMMAND>

Examples:

Terminal window
hourctl route add --group hq --system attendance --to acme
hourctl route list --person hq/1001 --for-endpoint office

Commands:

  • list: List an endpoint’s, a group’s or a person’s routes.
  • add: Add a route.
  • remove: Remove route N, as route list numbers them.

hourctl route list

List an endpoint’s, a group’s or a person’s routes.

For a person, the defaults (with —endpoint, that endpoint’s over the group’s), their own routes, and the candidates those make.

hourctl route list [OPTIONS]

Options:

  • --endpoint <ENDPOINT>: An endpoint’s default routes, by its id.
  • --group <GROUP>: A sync group’s default routes, by its id.
  • --person <GROUP/USER>: A person’s own routes, as GROUP/USER.
  • --for-endpoint <ENDPOINT>: With —person: the endpoint whose punches are meant.

Example:

Terminal window
hourctl route list --person hq/1001 --for-endpoint office

hourctl route add

Add a route.

A default route (—endpoint, —group) names no person: their id there is their external id in the system. A person’s own route may name their id there (—person-id). Adding one to a person routes their unrouted punches again.

hourctl route add [OPTIONS] --system <SYSTEM> --to <TENANT>

Options:

  • --endpoint <ENDPOINT>: An endpoint’s default routes, by its id.
  • --group <GROUP>: A sync group’s default routes, by its id.
  • --person <GROUP/USER>: A person’s own routes, as GROUP/USER.
  • --system <SYSTEM>: The receiving system, e.g. attendance.
  • --to <TENANT>: The tenant in that system the punches go to.
  • --person-id <PERSON_ID>: The person’s id in that system (a person’s own route only).
  • --code <KEY=VALUE>...: A code for the receiver, KEY=VALUE; repeat for several.

Example:

Terminal window
hourctl route add --person hq/1001 --system attendance --to agency-a --person-id 11 --code work_code=7

hourctl route remove

Remove route N, as route list numbers them.

hourctl route remove [OPTIONS] <N>

Arguments:

  • <N>: The route’s number, from 1.

Options:

  • --endpoint <ENDPOINT>: An endpoint’s default routes, by its id.
  • --group <GROUP>: A sync group’s default routes, by its id.
  • --person <GROUP/USER>: A person’s own routes, as GROUP/USER.

Example:

Terminal window
hourctl route remove --group hq 2

hourctl unrouted

List a sync group’s unrouted punches, or route them.

An unrouted punch goes to no system until it is routed: worked out again (after routes were added), or sent to a route given. Routed, it goes out again with the same id.

hourctl unrouted [OPTIONS] <COMMAND>

Examples:

Terminal window
hourctl unrouted list hq
hourctl unrouted route hq 0f3c2a9b --system attendance --to agency-b

Commands:

  • list: List a group’s unrouted punches: id, person, device, time, why, and how many candidates.
  • route: Route unrouted punches.

hourctl unrouted list

List a group’s unrouted punches: id, person, device, time, why, and how many candidates.

hourctl unrouted list [OPTIONS] <GROUP>

Arguments:

  • <GROUP>: The group’s id, e.g. hq.

Options:

  • --user-id <USER_ID>: Only this person’s (their user id).

Example:

Terminal window
hourctl unrouted list hq --user-id 1001

hourctl unrouted route

Route unrouted punches.

Without a punch id, the group’s (or —user-id’s) are worked out again with the routes and policies as they are now. With one, it is worked out again, or sent to —system and —to (with —person-id).

hourctl unrouted route [OPTIONS] <GROUP> [ID]

Arguments:

  • <GROUP>: The group’s id, e.g. hq.
  • [ID]: The punch’s id.

Options:

  • --user-id <USER_ID>: Only this person’s (without a punch id).
  • --system <SYSTEM>: The receiving system to send it to.
  • --to <TENANT>: The tenant in that system.
  • --person-id <PERSON_ID>: The person’s id there.

Example:

Terminal window
hourctl unrouted route hq 0f3c2a9b --system attendance --to agency-b --person-id 22