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 startpnpm exec gio startyarn gio startbunx gio startgio start [--port <port>] [--host <ip>] [--open]Reference
| Option | Type | Default | Description |
|---|---|---|---|
-p, --port <port> | number | 3000 | The 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> | string | 0.0.0.0 | The 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. |
--open | boolean | false | Open the local URL in a browser once the app is ready. |
-h, --help | boolean | - | 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.productionand.envfiles 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_sessionguards needGIO_SESSION_SECRET; without it every guarded request is denied.[server] workersapplies, and nothing is watched. The dev endpoints (/_gio/devtools, the error overlay) do not exist.
GioJS 0.1.0-beta.8 (production)
- Local: http://localhost:3000
- Network: http://10.0.0.12:3000Ctrl+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
PORT=8080 gio startHosting platforms set PORT; gio start needs nothing else. A --port flag would override it.
Behind a reverse proxy on the same machine
gio start --host 127.0.0.1 --port 3000Bind 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
gio doctor --prod && gio startgio 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 startneedsnode_modules(the Node worker runs your app from source throughtsx). To deploy one folder withoutnode_modules, usegio build standalone.- Scaffolded apps run
cross-env NODE_ENV=production giojs-serverfromnpm start; it starts the same server without the ready banner (seegiojs-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:
0after a clean shutdown,1when the server fails to start or exits with an error,2for a usage error.
Related
Version history
| Version | Changes |
|---|---|
v0.1.0-beta.8 | Introduced. |