Server Lifecycle Commands
Commands for starting the server, checking its health, running diagnostics, and managing the active mode.
shark serve
Start the SharkAuth HTTP server (admin API, dashboard, OAuth endpoints).
Synopsis
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--proxy-upstream | string | (none) | Mount a reverse proxy to this upstream URL (e.g. http://localhost:3000) |
--no-prompt | bool | false | Skip the first-boot browser-open prompt (for CI / headless environments) |
--verbose / -v | bool | false | Enable debug-level logging to stderr |
First-boot behavior (F4)
On the very first run against an empty database, shark serve:
- Runs all pending database migrations automatically.
- Generates RS256 JWT signing keys and stores them in the database.
- Creates an initial admin API key and writes it to
admin.key.firstbootbeside the database. - Prints a branded header with version, binary size, and URLs.
- Opens the dashboard in the default browser (unless
--no-promptis set).
On subsequent runs the re-run banner shows the admin key location and detected mode.
Examples
Gotchas
- The server binds to the port configured in
server.port(default 8080). Runshark doctorbeforeserveto confirm the port is free. admin.key.firstbootis written once. If deleted, you can still find the key in the database'sapi_keystable, or runshark reset keyto rotate.SIGINT/SIGTERMtriggers a graceful shutdown.
shark doctor
Run 9 self-diagnostic checks against a configured SharkAuth deployment. Introduced in F5.
Synopsis
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--json | bool | false | Emit one JSON object per check to stdout (machine-readable) |
Checks performed
| Check | What it verifies |
|---|---|
config | Config loads without error; prints base_url, port, db path |
db_writability | SQLite database opens and accepts a write transaction |
migrations | All goose migrations are applied (no pending) |
jwt_keys | At least one active RS256 signing key exists; warns if >90 days old |
port_bind | Configured port is free (server is not already running) |
base_url | GET <base_url>/api/v1/health returns HTTP 200 |
admin_key | admin.key.firstboot file exists OR at least one api_keys row in DB |
smtp | If SMTP is configured, TCP connectivity (and TLS for port 465) is verified |
vault | server.secret is set and AES-256-GCM round-trip works |
Exit codes
| Code | Meaning |
|---|---|
0 | All checks passed |
1 | One or more checks failed |
2 | Config could not be loaded (fatal — no checks run) |
Examples
JSON output format
shark health
Ping the /healthz endpoint of a running shark instance.
Synopsis
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--url | string | http://localhost:8080 | Base URL of the running instance |
--json | bool | false | Emit JSON response |
Examples
shark version
Print the shark binary version and the branded header.
Synopsis
No flags. Prints the build-injected version string (e.g. v0.1.0) or dev if running from source.
Examples
shark mode
Get or set the active database mode (dev or prod).
Synopsis
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--json | bool | false | Output as JSON {"mode":"dev"} |
Behavior
- With no argument: reads and prints the current mode from
~/.shark/state. - With
devorprod: writes the new mode to~/.shark/state. Takes effect on nextshark serve.
Examples
shark reset
Wipe a database or rotate the admin API key via the running server's admin API.
Synopsis
Arguments
| Argument | Effect |
|---|---|
dev | Wipe dev.db, regenerate all secrets (no confirmation) |
prod | Wipe shark.db, regenerate secrets — requires typing RESET PROD |
key | Rotate the admin API key only (no data loss) |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--url | string | http://localhost:8080 | SharkAuth server base URL |
--key | string | (env) | Admin API key (or SHARK_ADMIN_KEY) |
--json | bool | false | Print JSON response |
Examples
Gotchas
reset prodrequires the confirmation phraseRESET PRODtyped interactively. Use--jsonto parse the new key from the response.- The new admin key is printed once in the response. Store it immediately.
shark debug decode-jwt
Decode and pretty-print a JWT (header + payload) without verifying the signature. Local operation — no server call.
Synopsis
Arguments
| Argument | Description |
|---|---|
<token> | The JWT string to decode (3-part base64url) |
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--json | bool | false | Emit {"header":{...},"payload":{...}} as JSON |
Examples
Gotchas
- The signature is not verified. This is a developer convenience tool only — do not use for security decisions.
- Requires exactly 3 dot-separated segments; exits with an error otherwise.