Reference·The gatewayIndex

The gateway

The background gateway: its verbs, what it installs per platform, logout, automatic start and updates.

.mdllms.txt

The gateway is the local server that shells attach to. The background gateway keeps it and the organism, a running Nodecode, up with no shell open.

Verbs

a shell
nodecode gateway
nodecode gateway on
nodecode gateway off
nodecode gateway restart
nodecode gateway logs --follow
VerbDoes
none, statusPrints the state: off, serving, waiting, starting, stopped, restarting, failed or unavailable.
onWrites the unit. Enables it. Starts it. On Linux, asks logind to keep it running after logout.
offDisables the unit, removes its file and stops the process. Writes gateway-off.
restartRestarts on the current build with the current config. Refused while the gateway is off.
logsPrints the last 60 log lines.
logs --follow, logs -fKeeps printing new lines. Command line only.
runRuns the gateway in the foreground. This is what the unit runs. Command line only.
help [VERB]Prints help.

/gateway [on | off | restart | logs | help] does the same from a shell. A shell is the terminal UI.

For a profile, add -p NAME:

a shell
nodecode -p NAME gateway on

While it serves, the status adds the pid, the port, the uptime and the build. It says whether the gateway starts at login. It lists the standing notices of cells.

What on installs

PlatformInstallsUnit file
LinuxA systemd user unit~/.config/systemd/user/nodecode-gateway.service
macOSA LaunchAgent~/Library/LaunchAgents/nodecode-gateway.plist
WindowsNothingNone

Windows: no background gateway. status, on, restart and logs say so. Run nodecode serve in a terminal you keep open.

On Linux the unit folder follows XDG_CONFIG_HOME when it is set.

HomeUnit name
~/.nodecode/nodecode-gateway
A profilenodecode-gateway-NAME
Another NODECODE_HOMEnodecode-gateway- plus 8 hex digits of the path's hash

The home is ~/.nodecode/ unless a profile or NODECODE_HOME names another.

SettingLinuxmacOS
Runsnodecode gateway runThe same, through a launcher
Restart after any exitAfter 5 sYes, at most once per 5 s
Watchdog30 sNone
Stop timeout60 s60 s
LogThe user journal~/Library/Logs/nodecode/nodecode-gateway.log

On macOS the launcher is copied once to ~/Library/Application Support/nodecode/launcher/1/nodecode.

on refuses to overwrite a unit file of that name that Nodecode did not write. off leaves such a file alone.

Shells and the gateway

SituationResult
A shell owns the store, then the gateway startsThe gateway waits. It takes the organism over when that shell closes.
The gateway serves, then a shell opensThe shell attaches. Its footer shows the gateway's port.
/gateway off from an attached shellThe gateway stops. That shell takes the organism over.

See The organism.

Logout

PlatformBehaviour
Linux, linger onThe gateway starts at boot. It keeps running after logout.
Linux, linger offThe gateway starts at login. It stops at logout.
macOSThe agent starts at login. It stops at logout. launchd has no linger.

on runs loginctl enable-linger for your account. If your system refuses, the status says so. Then run once:

a shell
sudo loginctl enable-linger $USER

Run the same command when the status says systemd has no user manager.

Automatic start

A cell is a folder of code under ~/.nodecode/cells/. Four cells turn the gateway on by themselves:

CellWhen
ChannelsA bot starts.
CronA job is scheduled, or active jobs exist at start.
LinkThe link is on.
PrsThe pull request watch starts.

Every attached shell shows a notice when this happens.

A cell does not turn the gateway on in these cases:

  • ~/.nodecode/gateway-off exists.
  • The organism runs with --ephemeral.
  • The platform is Windows.

gateway-off

nodecode gateway off writes the file ~/.nodecode/gateway-off.

While the file exists, no cell turns the gateway on. Bots and cron jobs then run only while a shell is open.

nodecode gateway on deletes the file.

Updates

The unit names the installer's current link. A restart runs the build installed last.

EventResult
The installer finishes, gateway runningThe installer runs nodecode gateway restart for it.
The installer finishes, gateway stoppedNothing. The next start runs the new build.
nodecode update needs a restartThe organism restarts itself through the unit at an idle moment.
nodecode gateway restartRewrites the unit first if the binary path or PATH changed.

The installer restarts only units that Nodecode wrote. See Updates.

Esc

    Loading the index…

    ↑↓ moveEnter openEsc close