|
1 | 1 | --- |
2 | 2 | sidebar_position: 2 |
3 | | -title: ColdStarter System |
4 | | -description: Understand how Druid's ColdStarter system enables wake-on-demand automation and 70-90% cost savings |
| 3 | +title: ColdStarter |
| 4 | +description: Wake-on-demand system for cost savings |
5 | 5 | --- |
6 | 6 |
|
7 | | -# ColdStarter System |
| 7 | +# ColdStarter |
8 | 8 |
|
9 | | -ColdStarter is Druid's intelligent wake-on-demand system that automatically starts your game server when players connect, while keeping costs near zero when idle. It's the core technology that makes Druid cost-effective for hobby servers. |
10 | | - |
11 | | -## What is ColdStarter? |
12 | | - |
13 | | -ColdStarter acts as a lightweight listener proxy that intercepts incoming connections to your game server. When a player tries to connect: |
14 | | - |
15 | | -1. **Sleeping**: Server is powered down, consuming minimal resources (~0 cost) |
16 | | -2. **Wake signal**: Player connects, ColdStarter intercepts the connection |
17 | | -3. **Starting**: ColdStarter wakes the server in the background |
18 | | -4. **Ready**: Player is connected to the now-running server |
19 | | - |
20 | | -The magic? **Your server still appears "online" in server browsers even when sleeping.** |
21 | | - |
22 | | -## Key Benefits |
23 | | - |
24 | | -### 💰 **70-90% Cost Savings** |
25 | | - |
26 | | -Pay only for active playtime, not idle time. A typical hobby server might run: |
27 | | -- **Traditional hosting**: 24/7 = 720 hours/month |
28 | | -- **With ColdStarter**: 50-150 hours/month actual playtime |
29 | | - |
30 | | -**Example cost breakdown:** |
31 | | -``` |
32 | | -Traditional: $10/month × 720 hours = $10 |
33 | | -Druid: $0.014/hour × 100 hours = $1.40/month |
34 | | -
|
35 | | -Savings: 86% |
36 | | -``` |
37 | | - |
38 | | -### ⚡ **Seamless User Experience** |
39 | | - |
40 | | -- Server shows as "online" in Minecraft/Rust/etc. server browsers |
41 | | -- Players connect normally (10-30 second wake time) |
42 | | -- Status messages show "Starting..." or "Waking up..." |
43 | | -- No configuration needed by players |
44 | | - |
45 | | -### 🌍 **Always Available** |
46 | | - |
47 | | -Your server is accessible 24/7, but only costs money when actually in use. Perfect for: |
48 | | -- Hobby servers with irregular play schedules |
49 | | -- Friend groups in different time zones |
50 | | -- Testing and development environments |
51 | | -- Event-based servers |
| 9 | +ColdStarter automatically wakes your server when players connect, then puts it to sleep when idle. You only pay for active time. |
52 | 10 |
|
53 | 11 | ## How It Works |
54 | 12 |
|
55 | | -### Architecture |
56 | | - |
57 | | -``` |
58 | | -Player → ColdStarter Listener → [Wake] → Game Server |
59 | | - ↓ |
60 | | - Lua Packet Handler |
61 | | - (Server status response) |
62 | | -``` |
63 | | - |
64 | | -### 1. Listener Proxy |
65 | | - |
66 | | -When your server goes idle (no players for X minutes): |
67 | | -- Main game server shuts down |
68 | | -- Lightweight ColdStarter listener starts on the same port |
69 | | -- Memory footprint: ~10-50MB (vs 2-8GB for game server) |
70 | | - |
71 | | -### 2. Packet Handler |
72 | | - |
73 | | -ColdStarter uses **Lua packet handlers** to understand game-specific connection protocols. |
74 | | - |
75 | | -**Example**: [Minecraft packet handler (minecraft.lua)](https://github.com/highcard-dev/scrolls/blob/main/scrolls/minecraft/papermc/1.21.7/packet_handler/minecraft.lua) |
76 | | - |
77 | | -The handler intercepts incoming packets, responds with server status, and triggers wake when players connect. |
78 | | - |
79 | | -Each game has a custom packet handler: |
80 | | -- **Minecraft**: Responds to status + login packets |
81 | | -- **Rust**: Responds to query protocol |
82 | | -- **Source games**: Responds to A2S_INFO queries |
83 | | -- **Hytale**: Protocol TBD (ready for launch) |
| 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 |
84 | 17 |
|
85 | | -### 3. Wake Process |
| 18 | +Your server still shows as "online" in server browsers while sleeping. |
86 | 19 |
|
87 | | -When a player attempts to connect: |
| 20 | +## Cost Savings |
88 | 21 |
|
89 | | -1. **Intercept**: ColdStarter receives connection |
90 | | -2. **Respond**: Send "Starting..." status to player |
91 | | -3. **Wake**: Restore server container from snapshot |
92 | | -4. **Handoff**: Transfer connection to real server |
93 | | -5. **Cleanup**: ColdStarter listener shuts down |
| 22 | +Typical hobby server: |
| 23 | +- **Without ColdStarter**: 720 hours/month (24/7) |
| 24 | +- **With ColdStarter**: 100 hours/month (actual playtime) |
94 | 25 |
|
95 | | -Typical wake time: **10-30 seconds** (varies by game/world size) |
96 | | - |
97 | | -### 4. Server Browser Integration |
98 | | - |
99 | | -The clever part: **Server browsers never know the server is asleep.** |
100 | | - |
101 | | -- **Minecraft**: Shows in server list with "🕐 Waiting..." status |
102 | | -- **Rust**: Appears in Rust+ app and server browser |
103 | | -- **Steam games**: Shows in Steam server browser |
104 | | -- **Direct connect**: Works normally with IP:PORT |
105 | | - |
106 | | -## Supported Games |
107 | | - |
108 | | -ColdStarter has optimized handlers for: |
109 | | - |
110 | | -| Game | Status | Protocol Handler | |
111 | | -|------|--------|------------------| |
112 | | -| Minecraft (all variants) | ✅ Stable | `minecraft.lua` | |
113 | | -| Rust | ✅ Stable | `rust.lua` | |
114 | | -| Hytale | ✅ Ready | `hytale.lua` | |
115 | | -| ARK: Survival | ✅ Stable | LGSM generic | |
116 | | -| Palworld | ✅ Stable | LGSM generic | |
117 | | -| Valheim | ✅ Stable | LGSM generic | |
118 | | -| 7 Days to Die | ✅ Stable | LGSM generic | |
119 | | -| Other LGSM games | ✅ Stable | Generic handler | |
120 | | - |
121 | | -**Total**: 95 published scrolls with ColdStarter support |
| 26 | +**Result**: ~85% cost reduction |
122 | 27 |
|
123 | 28 | ## Configuration |
124 | 29 |
|
125 | | -ColdStarter is configured automatically per-scroll. Key settings: |
126 | | - |
127 | | -### Scroll Configuration |
| 30 | +Configured per-scroll via `scroll.yaml`: |
128 | 31 |
|
129 | 32 | ```yaml |
130 | | -# scroll.yaml |
131 | 33 | ports: |
132 | 34 | - name: game |
133 | 35 | port: 25565 |
134 | 36 | protocol: tcp |
135 | | - sleep_handler: "minecraft.lua" # Packet handler |
136 | | - check_activity: true # Monitor for idle |
137 | | - |
138 | | -coldstarter: |
139 | | - idle_timeout: 300 # Shutdown after 5min idle |
140 | | - wake_timeout: 60 # Max wake time |
141 | | - snapshot_mode: "auto" # Enable snapshots |
| 37 | + sleep_handler: packet_handler/minecraft.lua |
| 38 | + start_delay: 10 |
| 39 | + check_activity: true |
142 | 40 | ``` |
143 | 41 |
|
144 | | -### Advanced Options |
| 42 | +### Port Options |
145 | 43 |
|
146 | | -- **idle_timeout**: How long to wait before sleeping (seconds) |
147 | | -- **wake_timeout**: Max time allowed for wake (kills if exceeded) |
148 | | -- **snapshot_mode**: `auto` | `manual` | `none` |
149 | | -- **custom_handler**: Path to custom Lua packet handler |
| 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 |
150 | 48 |
|
151 | | -## Technical Details |
| 49 | +## Packet Handlers |
152 | 50 |
|
153 | | -### Packet Handler API |
| 51 | +Lua handlers respond to game protocols while server is asleep. |
154 | 52 |
|
155 | | -Lua handlers have access to: |
| 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 |
156 | 56 |
|
157 | 57 | ```lua |
158 | | --- Send data back to client |
| 58 | +-- Send data to client |
159 | 59 | sendData(string) |
160 | 60 |
|
161 | | --- Close connection |
162 | | -close(data) |
163 | | -
|
164 | | --- Trigger server wake + handoff |
| 61 | +-- Trigger server wake |
165 | 62 | finish() |
166 | 63 |
|
167 | | --- Get queue status (install/restore) |
| 64 | +-- Get snapshot/queue status |
168 | 65 | get_queue() |
169 | | -
|
170 | | --- Get snapshot progress |
171 | | -get_snapshot_mode() |
172 | 66 | get_snapshot_percentage() |
173 | | -
|
174 | | --- Time since wake started |
175 | 67 | get_finish_sec() |
176 | | -
|
177 | | --- Debug logging |
178 | | -debug_print(string) |
179 | 68 | ``` |
180 | 69 |
|
181 | | -### Custom Handlers |
| 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 |
182 | 79 |
|
183 | | -Create your own for unsupported games: |
| 80 | +Create `packet_handler/game.lua` in your scroll: |
184 | 81 |
|
185 | 82 | ```lua |
186 | | --- custom_game.lua |
187 | 83 | function handle(ctx, data) |
188 | | - -- 1. Parse incoming packet |
189 | | - local packet_type = parsePacket(data) |
190 | | - |
191 | | - -- 2. Handle status requests |
192 | | - if packet_type == "STATUS" then |
193 | | - sendData(buildStatusResponse({ |
194 | | - name = "My Server", |
195 | | - players = 0, |
196 | | - max_players = 20, |
197 | | - status = "Waking up..." |
198 | | - })) |
| 84 | + -- Parse packet |
| 85 | + if isStatusRequest(data) then |
| 86 | + sendData("Server starting...") |
199 | 87 | end |
200 | 88 | |
201 | | - -- 3. Handle connection attempts |
202 | | - if packet_type == "CONNECT" then |
203 | | - sendData("Please wait, server starting...") |
204 | | - finish() -- Wake the server |
| 89 | + -- Wake on connect |
| 90 | + if isConnectionAttempt(data) then |
| 91 | + finish() |
205 | 92 | end |
206 | 93 | end |
207 | 94 | ``` |
208 | | - |
209 | | -Place in `scrolls/<game>/packet_handler/custom_game.lua` |
210 | | - |
211 | | -## FAQ |
212 | | - |
213 | | -**Q: Can players still see my server when it's asleep?** |
214 | | -A: Yes! ColdStarter responds to status queries, so your server appears "online" with a "Starting..." message. |
215 | | - |
216 | | -**Q: What happens if multiple players connect at once?** |
217 | | -A: ColdStarter queues all connections and wakes the server once. All players connect when ready. |
218 | | - |
219 | | -**Q: Does this work with mods/plugins?** |
220 | | -A: Yes, ColdStarter is transparent to the game server. Mods/plugins work normally. |
221 | | - |
222 | | -**Q: Can I disable ColdStarter?** |
223 | | -A: Yes, set `coldstarter.enabled: false` in scroll.yaml or keep the server always-on. |
0 commit comments