GioJSdocs
On this page

gio start

Run the GioJS server in production mode. There is no build step: routes and client bundles are built at startup, pages render on demand and are cached in Rust.

npx gio start
bash
gio start [--port <port>] [--host <ip>] [--open]

Reference

OptionTypeDefaultDescription
-p, --port <port>number3000The port, 0-65535, passed to the server as GIO_PORT (which outranks PORT and [server] port; without the flag those decide, then 3000).
-H, --host <ip>string0.0.0.0The IP address to bind, passed as GIO_HOST (over [server] host). IPv4, or IPv6 with or without brackets; localhost means 127.0.0.1. Host names are a usage error.
--openbooleanfalseOpen the local URL in a browser once the app is ready.
-h, --helpboolean-Print the command's help and exit with 0.

Behavior

gio start works like gio dev (binary lookup, listen address from --check-config, ready banner, exit code passed through) with NODE_ENV=production, whatever the shell has. In production:

  • The .env.production.local, .env.local, .env.production and .env files load. Variables already in the environment win.
  • Error pages show an error reference (the digest in the log line) instead of the message, stack and code frame development shows.
  • require_session guards need GIO_SESSION_SECRET; without it every guarded request is denied.
  • [server] workers applies, and nothing is watched. The dev endpoints (/_gio/devtools, the error overlay) do not exist.
text
  GioJS 0.1.0-beta.8 (production)
  - Local:    http://localhost:3000
  - Network:  http://10.0.0.12:3000

Ctrl+C and SIGTERM start a graceful shutdown: the server stops accepting, drains in-flight requests, ends open event streams and gives each worker time to run plugin onShutdown hooks. On Unix gio forwards the signal to the server; on Windows the console delivers Ctrl+C to both. If gio itself is killed outright, the server notices its stdin pipe close and shuts down instead of lingering on the port.

Examples

A platform that assigns the port

bash
PORT=8080 gio start

Hosting platforms set PORT; gio start needs nothing else. A --port flag would override it.

Behind a reverse proxy on the same machine

bash
gio start --host 127.0.0.1 --port 3000

Bind loopback so only the proxy can connect, and list the proxy in [server] trusted_proxies (see Reverse proxies & client IPs).

Check the configuration before starting

bash
gio doctor --prod && gio start

gio doctor --prod exits with 1 on a problem that would break production, such as a missing GIO_SESSION_SECRET for require_session guards. The server does not refuse to start over that: it starts and denies every guarded request, and logs an error only when the secret is set but invalid.

Good to know

  • gio start needs node_modules (the Node worker runs your app from source through tsx). To deploy one folder without node_modules, use gio build standalone.
  • Scaffolded apps run cross-env NODE_ENV=production giojs-server from npm start; it starts the same server without the ready banner (see giojs-server).
  • The client code is bundled at every start, and the deployment id is derived from the app's code, so a restart of changed code invalidates the old cache entries on its own.
  • Exit codes: 0 after a clean shutdown, 1 when the server fails to start or exits with an error, 2 for a usage error.

Version history

VersionChanges
v0.1.0-beta.8Introduced.