@rip-lang/server 0.7.10 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -32
- package/package.json +1 -1
- package/server.rip +41 -0
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
9
|
-
`@rip-lang/server` is a production-grade application server written entirely in Rip. It provides multi-worker process management, hot reloading, automatic HTTPS, and mDNS service discovery — all in a single ~1,
|
|
9
|
+
`@rip-lang/server` is a production-grade application server written entirely in Rip. It provides multi-worker process management, hot reloading, automatic HTTPS, and mDNS service discovery — all in a single ~1,200 line file.
|
|
10
10
|
|
|
11
|
-
- **`server.rip`** (~1,
|
|
11
|
+
- **`server.rip`** (~1,200 lines) — Complete server: CLI, workers, load balancing, TLS, mDNS
|
|
12
12
|
|
|
13
13
|
**Core Philosophy**: Application servers should be simple, fast, and reliable. No complex configuration files. No dependency on external process managers. Just run your app.
|
|
14
14
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
- **Multi-Worker Architecture** — Automatic worker spawning based on CPU cores
|
|
18
18
|
- **Hot Module Reloading** — File-watch based reloading in development
|
|
19
|
+
- **Directory Watching** — Watch all `.rip` files with `-w` flag for instant reload
|
|
19
20
|
- **Rolling Restarts** — Zero-downtime deployments
|
|
20
21
|
- **Automatic HTTPS** — TLS with mkcert or self-signed certificates
|
|
21
22
|
- **mDNS Discovery** — `.local` hostname advertisement
|
|
@@ -39,19 +40,25 @@ bun add -g rip-lang @rip-lang/server
|
|
|
39
40
|
### Running Your App
|
|
40
41
|
|
|
41
42
|
```bash
|
|
42
|
-
#
|
|
43
|
+
# From your app directory (uses ./index.rip by default)
|
|
44
|
+
rip-server
|
|
45
|
+
|
|
46
|
+
# With file watching (recommended for development)
|
|
47
|
+
rip-server -w
|
|
48
|
+
|
|
49
|
+
# Name your app (for mDNS: myapp.local)
|
|
50
|
+
rip-server myapp
|
|
51
|
+
|
|
52
|
+
# Explicit entry file
|
|
43
53
|
rip-server ./app.rip
|
|
44
54
|
|
|
45
55
|
# HTTP only mode
|
|
46
|
-
rip-server http
|
|
47
|
-
|
|
48
|
-
# With mDNS alias
|
|
49
|
-
rip-server ./app.rip@myapp
|
|
56
|
+
rip-server http
|
|
50
57
|
```
|
|
51
58
|
|
|
52
59
|
### Example App
|
|
53
60
|
|
|
54
|
-
Create `
|
|
61
|
+
Create `index.rip`:
|
|
55
62
|
|
|
56
63
|
```coffee
|
|
57
64
|
import { get, read, start } from '@rip-lang/api'
|
|
@@ -72,7 +79,7 @@ start()
|
|
|
72
79
|
Run it:
|
|
73
80
|
|
|
74
81
|
```bash
|
|
75
|
-
rip-server
|
|
82
|
+
rip-server -w
|
|
76
83
|
```
|
|
77
84
|
|
|
78
85
|
Test it:
|
|
@@ -88,23 +95,131 @@ curl http://localhost/users/42
|
|
|
88
95
|
# {"user":{"id":42,"name":"User 42"}}
|
|
89
96
|
|
|
90
97
|
curl http://localhost/status
|
|
91
|
-
# {"status":"healthy","app":"myapp","workers":5,"ports":{"
|
|
98
|
+
# {"status":"healthy","app":"myapp","workers":5,"ports":{"https":443}}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## App Path & Naming
|
|
102
|
+
|
|
103
|
+
### Entry File Resolution
|
|
104
|
+
|
|
105
|
+
When you run `rip-server`, it looks for your app's entry file:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# No arguments: looks for index.rip (or index.ts) in current directory
|
|
109
|
+
rip-server
|
|
110
|
+
|
|
111
|
+
# Directory path: looks for index.rip (or index.ts) in that directory
|
|
112
|
+
rip-server ./myapp/
|
|
113
|
+
|
|
114
|
+
# Explicit file: uses that file directly
|
|
115
|
+
rip-server ./app.rip
|
|
116
|
+
rip-server ./src/server.ts
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### App Naming
|
|
120
|
+
|
|
121
|
+
The **app name** is used for mDNS discovery (e.g., `myapp.local`) and logging. It's determined by:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Default: current directory name becomes app name
|
|
125
|
+
~/projects/api$ rip-server # app name = "api"
|
|
126
|
+
|
|
127
|
+
# Explicit name: pass a name that's not a file path
|
|
128
|
+
rip-server myapp # app name = "myapp"
|
|
129
|
+
|
|
130
|
+
# With aliases: name@alias1,alias2
|
|
131
|
+
rip-server myapp@api,backend # accessible at myapp.local, api.local, backend.local
|
|
132
|
+
|
|
133
|
+
# Path with alias
|
|
134
|
+
rip-server ./app.rip@myapp # explicit file + custom app name
|
|
92
135
|
```
|
|
93
136
|
|
|
137
|
+
**Examples:**
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# In ~/projects/api/ with index.rip
|
|
141
|
+
rip-server # app = "api", entry = ./index.rip
|
|
142
|
+
rip-server -w # same, with file watching
|
|
143
|
+
rip-server myapp # app = "myapp", entry = ./index.rip
|
|
144
|
+
rip-server myapp -w # same, with file watching
|
|
145
|
+
rip-server ./server.rip # app = "api", entry = ./server.rip
|
|
146
|
+
rip-server ./server.rip@myapp # app = "myapp", entry = ./server.rip
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## File Watching
|
|
150
|
+
|
|
151
|
+
### Development Mode with `-w`/`--watch`
|
|
152
|
+
|
|
153
|
+
The `-w` flag enables **directory watching** — any `.rip` file change in your app directory triggers an automatic hot reload:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Watch all .rip files (default pattern: *.rip)
|
|
157
|
+
rip-server -w
|
|
158
|
+
rip-server --watch
|
|
159
|
+
|
|
160
|
+
# Watch a custom pattern
|
|
161
|
+
rip-server -w=*.ts
|
|
162
|
+
rip-server --watch=*.tsx
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**How it works:**
|
|
166
|
+
|
|
167
|
+
1. Uses OS-native file watching (FSEvents on macOS, inotify on Linux)
|
|
168
|
+
2. Watches the entire app directory recursively
|
|
169
|
+
3. When a matching file changes, touches the entry file
|
|
170
|
+
4. The existing hot-reload mechanism detects the change and does a rolling restart
|
|
171
|
+
|
|
172
|
+
**This is efficient:**
|
|
173
|
+
|
|
174
|
+
- Single watcher in the main process (not per-worker)
|
|
175
|
+
- No polling — OS notifies on changes
|
|
176
|
+
- Zero overhead when files aren't changing
|
|
177
|
+
|
|
178
|
+
**Examples:**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Typical development setup
|
|
182
|
+
rip-server -w # Watch *.rip files
|
|
183
|
+
|
|
184
|
+
# TypeScript project
|
|
185
|
+
rip-server -w=*.ts # Watch *.ts files
|
|
186
|
+
|
|
187
|
+
# React/frontend project
|
|
188
|
+
rip-server -w=*.tsx # Watch *.tsx files
|
|
189
|
+
|
|
190
|
+
# Multiple concerns? Just use the broader pattern
|
|
191
|
+
rip-server -w=*.rip # Only Rip files (default)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Without `-w`:** Only the entry file (`index.rip`) is watched. Changes to imported files won't trigger reload unless you also touch the entry file.
|
|
195
|
+
|
|
94
196
|
## CLI Reference
|
|
95
197
|
|
|
96
198
|
### Basic Syntax
|
|
97
199
|
|
|
98
200
|
```bash
|
|
99
|
-
rip-server [flags]
|
|
201
|
+
rip-server [flags] [app-path] [app-name]
|
|
202
|
+
rip-server [flags] [app-path]@<alias1>,<alias2>,...
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Getting Help
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
rip-server -h # Show help
|
|
209
|
+
rip-server --help # Show help
|
|
210
|
+
rip-server -v # Show version
|
|
211
|
+
rip-server --version # Show version
|
|
100
212
|
```
|
|
101
213
|
|
|
102
214
|
### Flags
|
|
103
215
|
|
|
104
216
|
| Flag | Description | Default |
|
|
105
217
|
|------|-------------|---------|
|
|
218
|
+
| `-h`, `--help` | Show help and exit | — |
|
|
106
219
|
| `-v`, `--version` | Show version and exit | — |
|
|
107
|
-
| `--
|
|
220
|
+
| `-w`, `--watch` | Watch `*.rip` files for changes | Disabled |
|
|
221
|
+
| `-w=<glob>`, `--watch=<glob>` | Watch custom pattern (e.g., `*.ts`) | — |
|
|
222
|
+
| `--env=<mode>` | Environment mode (`dev`, `prod`) | `development` |
|
|
108
223
|
| `--debug` | Enable debug logging | Disabled |
|
|
109
224
|
| `--static` | Disable hot reload (production) | Hot reload enabled |
|
|
110
225
|
| `http` | HTTP-only mode (no HTTPS) | HTTPS enabled |
|
|
@@ -124,9 +239,6 @@ rip-server [flags] <app-path>[@alias1,alias2,...]
|
|
|
124
239
|
### Subcommands
|
|
125
240
|
|
|
126
241
|
```bash
|
|
127
|
-
# Show version
|
|
128
|
-
rip-server --version
|
|
129
|
-
|
|
130
242
|
# Stop running server
|
|
131
243
|
rip-server stop
|
|
132
244
|
|
|
@@ -137,26 +249,32 @@ rip-server list
|
|
|
137
249
|
### Examples
|
|
138
250
|
|
|
139
251
|
```bash
|
|
252
|
+
# Development with file watching (recommended)
|
|
253
|
+
rip-server -w
|
|
254
|
+
|
|
140
255
|
# Development: HTTP on any available port
|
|
141
|
-
rip-server http
|
|
256
|
+
rip-server http
|
|
142
257
|
|
|
143
258
|
# Development: HTTPS with mkcert
|
|
144
|
-
rip-server --auto-tls
|
|
259
|
+
rip-server --auto-tls
|
|
145
260
|
|
|
146
261
|
# Production: 8 workers, HTTPS, no hot reload
|
|
147
|
-
rip-server --env=prod w:8
|
|
148
|
-
|
|
149
|
-
# Debug mode to troubleshoot issues
|
|
150
|
-
rip-server --debug http app.rip
|
|
262
|
+
rip-server --env=prod --static w:8
|
|
151
263
|
|
|
152
|
-
# Custom
|
|
153
|
-
rip-server http:3000
|
|
264
|
+
# Custom port
|
|
265
|
+
rip-server http:3000
|
|
154
266
|
|
|
155
267
|
# With mDNS aliases (accessible as myapp.local and api.local)
|
|
156
|
-
rip-server
|
|
268
|
+
rip-server myapp@api
|
|
269
|
+
|
|
270
|
+
# Watch TypeScript files
|
|
271
|
+
rip-server -w=*.ts
|
|
272
|
+
|
|
273
|
+
# Debug mode to troubleshoot issues
|
|
274
|
+
rip-server --debug -w
|
|
157
275
|
|
|
158
276
|
# Restart workers after 5000 requests or 1 hour
|
|
159
|
-
rip-server r:5000,3600s
|
|
277
|
+
rip-server r:5000,3600s
|
|
160
278
|
```
|
|
161
279
|
|
|
162
280
|
## Architecture
|
|
@@ -201,7 +319,14 @@ When `RIP_WORKER_MODE=1` is set, the same `server.rip` file runs as a worker ins
|
|
|
201
319
|
|
|
202
320
|
### Hot Reloading
|
|
203
321
|
|
|
204
|
-
|
|
322
|
+
In development mode, the server watches for file changes:
|
|
323
|
+
|
|
324
|
+
- **Default**: Only the entry file is watched
|
|
325
|
+
- **With `-w`**: All matching files in the app directory are watched
|
|
326
|
+
|
|
327
|
+
When a change is detected, a rolling restart of all workers is triggered — zero downtime.
|
|
328
|
+
|
|
329
|
+
Use `--static` in production to disable hot reload entirely.
|
|
205
330
|
|
|
206
331
|
### Worker Lifecycle
|
|
207
332
|
|
|
@@ -233,7 +358,7 @@ Certificates are stored in `~/.rip/certs/`.
|
|
|
233
358
|
### Custom Certificates
|
|
234
359
|
|
|
235
360
|
```bash
|
|
236
|
-
rip-server --cert=/path/to/cert.pem --key=/path/to/key.pem
|
|
361
|
+
rip-server --cert=/path/to/cert.pem --key=/path/to/key.pem
|
|
237
362
|
```
|
|
238
363
|
|
|
239
364
|
## mDNS Service Discovery
|
|
@@ -242,10 +367,10 @@ The server automatically advertises itself via mDNS (Bonjour/Zeroconf):
|
|
|
242
367
|
|
|
243
368
|
```bash
|
|
244
369
|
# App accessible at myapp.local
|
|
245
|
-
rip-server
|
|
370
|
+
rip-server myapp
|
|
246
371
|
|
|
247
372
|
# Multiple aliases
|
|
248
|
-
rip-server
|
|
373
|
+
rip-server myapp@api,backend
|
|
249
374
|
```
|
|
250
375
|
|
|
251
376
|
Requires `dns-sd` (available on macOS by default).
|
|
@@ -318,19 +443,22 @@ The dashboard uses the same mDNS infrastructure as your app, so it's always avai
|
|
|
318
443
|
|
|
319
444
|
## Troubleshooting
|
|
320
445
|
|
|
321
|
-
**Port 80 requires sudo**: Use `http:3000` or another high port, or run with sudo.
|
|
446
|
+
**Port 80/443 requires sudo**: Use `http:3000` or another high port, or run with sudo.
|
|
322
447
|
|
|
323
448
|
**mDNS not working**: Ensure `dns-sd` is available (built into macOS). On Linux, install Avahi.
|
|
324
449
|
|
|
325
450
|
**Workers keep restarting**: Use `--debug` (or `RIP_DEBUG=1`) to see import errors in your app.
|
|
326
451
|
|
|
452
|
+
**Changes not triggering reload**: Make sure you're using `-w` flag for directory watching, or touch your entry file manually.
|
|
453
|
+
|
|
327
454
|
## Comparison with Other Servers
|
|
328
455
|
|
|
329
456
|
| Feature | rip-server | PM2 | Nginx |
|
|
330
457
|
|---------|------------|-----|-------|
|
|
331
458
|
| Pure Rip | ✅ | ❌ | ❌ |
|
|
332
|
-
| Single File | ✅ (~1,
|
|
459
|
+
| Single File | ✅ (~1,200 lines) | ❌ | ❌ |
|
|
333
460
|
| Hot Reload | ✅ | ✅ | ❌ |
|
|
461
|
+
| Directory Watch | ✅ (`-w` flag) | ✅ | ❌ |
|
|
334
462
|
| Multi-Worker | ✅ | ✅ | ✅ |
|
|
335
463
|
| Auto HTTPS | ✅ | ❌ | ❌ |
|
|
336
464
|
| mDNS | ✅ | ❌ | ❌ |
|
|
@@ -343,7 +471,6 @@ The dashboard uses the same mDNS infrastructure as your app, so it's always avai
|
|
|
343
471
|
|
|
344
472
|
- [ ] Request ID tracing for debugging
|
|
345
473
|
- [ ] Metrics endpoint (Prometheus format)
|
|
346
|
-
- [ ] Multi-file hot reload (watch entire directory)
|
|
347
474
|
- [ ] Static file serving
|
|
348
475
|
- [ ] Rate limiting
|
|
349
476
|
- [ ] Performance benchmarks
|
package/package.json
CHANGED
package/server.rip
CHANGED
|
@@ -1075,6 +1075,47 @@ main = ->
|
|
|
1075
1075
|
console.log 'rip-server (version unknown)'
|
|
1076
1076
|
return
|
|
1077
1077
|
|
|
1078
|
+
# Help flag
|
|
1079
|
+
if '--help' in process.argv or '-h' in process.argv
|
|
1080
|
+
console.log """
|
|
1081
|
+
rip-server - Pure Rip application server
|
|
1082
|
+
|
|
1083
|
+
Usage:
|
|
1084
|
+
rip-server [options] [app-path] [app-name]
|
|
1085
|
+
rip-server [options] [app-path]@<alias1>,<alias2>,...
|
|
1086
|
+
|
|
1087
|
+
Options:
|
|
1088
|
+
-h, --help Show this help
|
|
1089
|
+
-v, --version Show version
|
|
1090
|
+
-w, --watch Watch *.rip files for changes (hot reload)
|
|
1091
|
+
-w=<glob> Watch custom glob pattern (e.g., -w=*.ts)
|
|
1092
|
+
--static Disable hot reload
|
|
1093
|
+
--env=<mode> Set environment (dev, production)
|
|
1094
|
+
--debug Enable debug logging
|
|
1095
|
+
|
|
1096
|
+
Network:
|
|
1097
|
+
http HTTP only (no TLS)
|
|
1098
|
+
https HTTPS with auto TLS (default)
|
|
1099
|
+
<port> Listen on specific port
|
|
1100
|
+
--cert=<path> TLS certificate file
|
|
1101
|
+
--key=<path> TLS key file
|
|
1102
|
+
--auto-tls Generate TLS cert via mkcert
|
|
1103
|
+
--hsts Enable HSTS header
|
|
1104
|
+
--no-redirect-http Don't redirect HTTP to HTTPS
|
|
1105
|
+
|
|
1106
|
+
Workers:
|
|
1107
|
+
w:<n> Number of workers (default: cores/2)
|
|
1108
|
+
w:auto One worker per core
|
|
1109
|
+
r:<n>,<s>s Restart policy: max requests, max seconds
|
|
1110
|
+
|
|
1111
|
+
Examples:
|
|
1112
|
+
rip-server Start with ./index.rip
|
|
1113
|
+
rip-server -w Start with file watching
|
|
1114
|
+
rip-server myapp Start with app name "myapp"
|
|
1115
|
+
rip-server api -w 8080 Watch mode on port 8080
|
|
1116
|
+
"""
|
|
1117
|
+
return
|
|
1118
|
+
|
|
1078
1119
|
# Helper functions for subcommands
|
|
1079
1120
|
getKV = (prefix) ->
|
|
1080
1121
|
for tok in process.argv
|