Skip to content

Commit 6d4c871

Browse files
authored
docs: Add ColdStarter system documentation (#26)
Verified against source code, cut by 50%+ per feedback
1 parent cdac259 commit 6d4c871

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

docs/cli/coldstarter.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
sidebar_position: 2
3+
title: ColdStarter
4+
description: Wake-on-demand system for cost savings
5+
---
6+
7+
# ColdStarter
8+
9+
ColdStarter automatically wakes your server when players connect, then puts it to sleep when idle. You only pay for active time.
10+
11+
## How It Works
12+
13+
1. **Idle**: No players → server sleeps (minimal cost)
14+
2. **Connect**: Player tries to join → ColdStarter intercepts
15+
3. **Wake**: Server starts in background (10-30 seconds)
16+
4. **Play**: Player connects to running server
17+
18+
Your server still shows as "online" in server browsers while sleeping.
19+
20+
## Cost Savings
21+
22+
Typical hobby server:
23+
- **Without ColdStarter**: 720 hours/month (24/7)
24+
- **With ColdStarter**: 100 hours/month (actual playtime)
25+
26+
**Result**: ~85% cost reduction
27+
28+
## Configuration
29+
30+
Configured per-scroll via `scroll.yaml`:
31+
32+
```yaml
33+
ports:
34+
- name: game
35+
port: 25565
36+
protocol: tcp
37+
sleep_handler: packet_handler/minecraft.lua
38+
start_delay: 10
39+
check_activity: true
40+
```
41+
42+
### Port Options
43+
44+
- `sleep_handler` - Path to Lua packet handler (required for ColdStarter)
45+
- `start_delay` - Seconds to wait before port is ready
46+
- `check_activity` - Enable idle detection
47+
- `finish_after_command` - Wait for command to finish before opening port
48+
49+
## Packet Handlers
50+
51+
Lua handlers respond to game protocols while server is asleep.
52+
53+
**Example:** [minecraft.lua](https://github.com/highcard-dev/scrolls/blob/main/scrolls/minecraft/papermc/1.21.7/packet_handler/minecraft.lua)
54+
55+
### Lua API
56+
57+
```lua
58+
-- Send data to client
59+
sendData(string)
60+
61+
-- Trigger server wake
62+
finish()
63+
64+
-- Get snapshot/queue status
65+
get_queue()
66+
get_snapshot_percentage()
67+
get_finish_sec()
68+
```
69+
70+
## Supported Games
71+
72+
All 95 published scrolls support ColdStarter:
73+
- Minecraft (all variants)
74+
- Rust (Vanilla, Oxide)
75+
- Hytale
76+
- 10 LGSM games (Palworld, ARK, CS2, etc.)
77+
78+
## Custom Handlers
79+
80+
Create `packet_handler/game.lua` in your scroll:
81+
82+
```lua
83+
function handle(ctx, data)
84+
-- Parse packet
85+
if isStatusRequest(data) then
86+
sendData("Server starting...")
87+
end
88+
89+
-- Wake on connect
90+
if isConnectionAttempt(data) then
91+
finish()
92+
end
93+
end
94+
```

0 commit comments

Comments
 (0)