suthep 0.1.0 → 0.2.0-beta.1

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.
Files changed (72) hide show
  1. package/README.md +172 -71
  2. package/dist/commands/deploy.js +251 -37
  3. package/dist/commands/deploy.js.map +1 -1
  4. package/dist/commands/down.js +179 -0
  5. package/dist/commands/down.js.map +1 -0
  6. package/dist/commands/redeploy.js +59 -0
  7. package/dist/commands/redeploy.js.map +1 -0
  8. package/dist/commands/up.js +213 -0
  9. package/dist/commands/up.js.map +1 -0
  10. package/dist/index.js +36 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/utils/certbot.js +40 -3
  13. package/dist/utils/certbot.js.map +1 -1
  14. package/dist/utils/config-loader.js +30 -0
  15. package/dist/utils/config-loader.js.map +1 -1
  16. package/dist/utils/deployment.js +49 -16
  17. package/dist/utils/deployment.js.map +1 -1
  18. package/dist/utils/docker.js +396 -25
  19. package/dist/utils/docker.js.map +1 -1
  20. package/dist/utils/nginx.js +167 -8
  21. package/dist/utils/nginx.js.map +1 -1
  22. package/docs/README.md +25 -49
  23. package/docs/english/01-introduction.md +84 -0
  24. package/docs/english/02-installation.md +200 -0
  25. package/docs/english/03-quick-start.md +256 -0
  26. package/docs/english/04-configuration.md +358 -0
  27. package/docs/english/05-commands.md +363 -0
  28. package/docs/english/06-examples.md +456 -0
  29. package/docs/english/07-troubleshooting.md +417 -0
  30. package/docs/english/08-advanced.md +411 -0
  31. package/docs/english/README.md +48 -0
  32. package/docs/thai/01-introduction.md +84 -0
  33. package/docs/thai/02-installation.md +200 -0
  34. package/docs/thai/03-quick-start.md +256 -0
  35. package/docs/thai/04-configuration.md +358 -0
  36. package/docs/thai/05-commands.md +363 -0
  37. package/docs/thai/06-examples.md +456 -0
  38. package/docs/thai/07-troubleshooting.md +417 -0
  39. package/docs/thai/08-advanced.md +411 -0
  40. package/docs/thai/README.md +48 -0
  41. package/example/README.md +286 -53
  42. package/example/suthep-complete.yml +103 -0
  43. package/example/suthep-docker-only.yml +71 -0
  44. package/example/suthep-no-docker.yml +51 -0
  45. package/example/suthep-path-routing.yml +62 -0
  46. package/example/suthep.example.yml +89 -0
  47. package/package.json +1 -1
  48. package/src/commands/deploy.ts +322 -50
  49. package/src/commands/down.ts +240 -0
  50. package/src/commands/redeploy.ts +78 -0
  51. package/src/commands/up.ts +271 -0
  52. package/src/index.ts +62 -1
  53. package/src/types/config.ts +25 -24
  54. package/src/utils/certbot.ts +68 -6
  55. package/src/utils/config-loader.ts +40 -0
  56. package/src/utils/deployment.ts +61 -36
  57. package/src/utils/docker.ts +634 -30
  58. package/src/utils/nginx.ts +187 -4
  59. package/suthep-0.1.0-beta.1.tgz +0 -0
  60. package/suthep-0.1.1.tgz +0 -0
  61. package/suthep.example.yml +34 -0
  62. package/suthep.yml +39 -0
  63. package/test +0 -0
  64. package/docs/api-reference.md +0 -545
  65. package/docs/architecture.md +0 -367
  66. package/docs/commands.md +0 -273
  67. package/docs/configuration.md +0 -347
  68. package/docs/examples.md +0 -537
  69. package/docs/getting-started.md +0 -197
  70. package/docs/troubleshooting.md +0 -441
  71. package/example/docker-compose.yml +0 -72
  72. package/example/suthep.yml +0 -31
@@ -0,0 +1,417 @@
1
+ # Troubleshooting Guide
2
+
3
+ This guide helps you resolve common issues when using Suthep.
4
+
5
+ ## Common Issues
6
+
7
+ ### Configuration File Not Found
8
+
9
+ **Error:**
10
+ ```
11
+ Configuration file not found: suthep.yml
12
+ ```
13
+
14
+ **Solution:**
15
+ 1. Ensure you're in the correct directory
16
+ 2. Check if `suthep.yml` exists:
17
+ ```bash
18
+ ls -la suthep.yml
19
+ ```
20
+ 3. Create configuration file:
21
+ ```bash
22
+ suthep init
23
+ ```
24
+ 4. Or specify custom path:
25
+ ```bash
26
+ suthep deploy -f /path/to/config.yml
27
+ ```
28
+
29
+ ### Port Already in Use
30
+
31
+ **Error:**
32
+ ```
33
+ Error: Port 3000 is already in use
34
+ ```
35
+
36
+ **Solution:**
37
+ 1. Find what's using the port:
38
+ ```bash
39
+ sudo lsof -i :3000
40
+ # or
41
+ sudo netstat -tulpn | grep 3000
42
+ ```
43
+
44
+ 2. Stop the conflicting service or change the port in `suthep.yml`:
45
+ ```yaml
46
+ services:
47
+ - name: api
48
+ port: 3001 # Changed from 3000
49
+ ```
50
+
51
+ ### SSL Certificate Creation Failed
52
+
53
+ **Error:**
54
+ ```
55
+ Failed to obtain SSL certificate for example.com
56
+ ```
57
+
58
+ **Solutions:**
59
+
60
+ 1. **Check DNS Configuration**
61
+ ```bash
62
+ nslookup example.com
63
+ # Ensure domain points to your server IP
64
+ ```
65
+
66
+ 2. **Verify Ports Are Open**
67
+ ```bash
68
+ # Check if ports 80 and 443 are open
69
+ sudo ufw status
70
+ # or
71
+ sudo iptables -L
72
+ ```
73
+
74
+ 3. **Use Staging Mode for Testing**
75
+ ```yaml
76
+ certbot:
77
+ staging: true # Use staging to avoid rate limits
78
+ ```
79
+
80
+ 4. **Check Domain Accessibility**
81
+ ```bash
82
+ curl -I http://example.com
83
+ # Should return HTTP response
84
+ ```
85
+
86
+ 5. **Check Certbot Logs**
87
+ ```bash
88
+ sudo tail -f /var/log/letsencrypt/letsencrypt.log
89
+ ```
90
+
91
+ ### Nginx Configuration Errors
92
+
93
+ **Error:**
94
+ ```
95
+ nginx: configuration file /etc/nginx/nginx.conf test failed
96
+ ```
97
+
98
+ **Solutions:**
99
+
100
+ 1. **Test Nginx Configuration**
101
+ ```bash
102
+ sudo nginx -t
103
+ ```
104
+
105
+ 2. **Check Nginx Error Logs**
106
+ ```bash
107
+ sudo tail -f /var/log/nginx/error.log
108
+ ```
109
+
110
+ 3. **Check Generated Config Files**
111
+ ```bash
112
+ ls -la /etc/nginx/sites-available/
113
+ cat /etc/nginx/sites-available/example_com.conf
114
+ ```
115
+
116
+ 4. **Verify Nginx Syntax**
117
+ ```bash
118
+ sudo nginx -t -c /etc/nginx/nginx.conf
119
+ ```
120
+
121
+ ### Docker Container Issues
122
+
123
+ **Error:**
124
+ ```
125
+ Error: Docker container failed to start
126
+ ```
127
+
128
+ **Solutions:**
129
+
130
+ 1. **Check Docker Status**
131
+ ```bash
132
+ docker ps
133
+ docker ps -a # Show all containers
134
+ ```
135
+
136
+ 2. **Check Container Logs**
137
+ ```bash
138
+ docker logs <container-name>
139
+ ```
140
+
141
+ 3. **Verify Docker Image**
142
+ ```bash
143
+ docker images
144
+ docker pull <image-name> # Pull latest image
145
+ ```
146
+
147
+ 4. **Check Port Conflicts**
148
+ ```bash
149
+ docker ps | grep <port>
150
+ ```
151
+
152
+ 5. **Remove Old Containers**
153
+ ```bash
154
+ docker rm <container-name>
155
+ ```
156
+
157
+ ### Health Check Failures
158
+
159
+ **Error:**
160
+ ```
161
+ Health check failed for service api
162
+ ```
163
+
164
+ **Solutions:**
165
+
166
+ 1. **Verify Health Check Endpoint**
167
+ ```bash
168
+ curl http://localhost:3000/health
169
+ ```
170
+
171
+ 2. **Check Service is Running**
172
+ ```bash
173
+ # For Docker
174
+ docker ps
175
+ docker logs <container-name>
176
+
177
+ # For non-Docker
178
+ ps aux | grep <service>
179
+ ```
180
+
181
+ 3. **Increase Health Check Timeout**
182
+ ```yaml
183
+ deployment:
184
+ healthCheckTimeout: 60000 # Increase to 60 seconds
185
+ ```
186
+
187
+ 4. **Verify Health Check Path**
188
+ ```yaml
189
+ services:
190
+ - name: api
191
+ healthCheck:
192
+ path: /health # Ensure this path exists
193
+ ```
194
+
195
+ ### Permission Denied Errors
196
+
197
+ **Error:**
198
+ ```
199
+ Permission denied: /etc/nginx/sites-available/example.conf
200
+ ```
201
+
202
+ **Solutions:**
203
+
204
+ 1. **Use Sudo**
205
+ ```bash
206
+ sudo suthep deploy
207
+ ```
208
+
209
+ 2. **Check File Permissions**
210
+ ```bash
211
+ ls -la /etc/nginx/sites-available/
212
+ ```
213
+
214
+ 3. **Verify User Permissions**
215
+ ```bash
216
+ groups # Check your user groups
217
+ ```
218
+
219
+ ### Service Not Accessible
220
+
221
+ **Issue:** Service deployed but not accessible via domain.
222
+
223
+ **Solutions:**
224
+
225
+ 1. **Check Nginx Status**
226
+ ```bash
227
+ sudo systemctl status nginx
228
+ ```
229
+
230
+ 2. **Verify Site is Enabled**
231
+ ```bash
232
+ ls -la /etc/nginx/sites-enabled/
233
+ # Should have symlink to sites-available config
234
+ ```
235
+
236
+ 3. **Check DNS Resolution**
237
+ ```bash
238
+ nslookup example.com
239
+ dig example.com
240
+ ```
241
+
242
+ 4. **Test Local Connection**
243
+ ```bash
244
+ curl http://localhost:3000
245
+ ```
246
+
247
+ 5. **Check Firewall**
248
+ ```bash
249
+ sudo ufw status
250
+ sudo ufw allow 80/tcp
251
+ sudo ufw allow 443/tcp
252
+ ```
253
+
254
+ ### Zero-Downtime Deployment Issues
255
+
256
+ **Issue:** Deployment causes downtime.
257
+
258
+ **Solutions:**
259
+
260
+ 1. **Verify Deployment Strategy**
261
+ ```yaml
262
+ deployment:
263
+ strategy: rolling # or blue-green
264
+ ```
265
+
266
+ 2. **Check Container Health**
267
+ ```bash
268
+ docker ps
269
+ # Both old and new containers should be running during deployment
270
+ ```
271
+
272
+ 3. **Monitor Nginx Reload**
273
+ ```bash
274
+ sudo nginx -t # Test before reload
275
+ sudo systemctl reload nginx # Graceful reload
276
+ ```
277
+
278
+ ### Multiple Services on Same Domain
279
+
280
+ **Issue:** Path-based routing not working.
281
+
282
+ **Solutions:**
283
+
284
+ 1. **Verify Path Configuration**
285
+ ```yaml
286
+ services:
287
+ - name: api
288
+ path: /api # Ensure path is set
289
+ - name: ui
290
+ path: / # Root path
291
+ ```
292
+
293
+ 2. **Check Nginx Config**
294
+ ```bash
295
+ cat /etc/nginx/sites-available/example_com.conf
296
+ # Should have location blocks for each path
297
+ ```
298
+
299
+ 3. **Test Paths**
300
+ ```bash
301
+ curl http://example.com/api/health
302
+ curl http://example.com/
303
+ ```
304
+
305
+ ## Debugging Tips
306
+
307
+ ### Enable Verbose Output
308
+
309
+ Some commands support verbose output. Check logs:
310
+
311
+ ```bash
312
+ # Check Nginx logs
313
+ sudo tail -f /var/log/nginx/error.log
314
+ sudo tail -f /var/log/nginx/access.log
315
+
316
+ # Check Docker logs
317
+ docker logs <container-name>
318
+
319
+ # Check system logs
320
+ sudo journalctl -u nginx -f
321
+ ```
322
+
323
+ ### Test Configuration
324
+
325
+ Before deploying, test your configuration:
326
+
327
+ ```bash
328
+ # Validate YAML syntax
329
+ yamllint suthep.yml
330
+
331
+ # Test Nginx config
332
+ sudo nginx -t
333
+
334
+ # Test Docker image
335
+ docker run --rm <image-name>
336
+ ```
337
+
338
+ ### Step-by-Step Deployment
339
+
340
+ Deploy step by step to isolate issues:
341
+
342
+ ```bash
343
+ # 1. Deploy without Nginx
344
+ suthep deploy --no-nginx
345
+
346
+ # 2. Deploy without HTTPS
347
+ suthep deploy --no-https
348
+
349
+ # 3. Full deployment
350
+ suthep deploy
351
+ ```
352
+
353
+ ## Getting Help
354
+
355
+ If you're still experiencing issues:
356
+
357
+ 1. **Check Logs**
358
+ - Nginx: `/var/log/nginx/`
359
+ - Certbot: `/var/log/letsencrypt/`
360
+ - Docker: `docker logs <container>`
361
+
362
+ 2. **Verify Configuration**
363
+ - Review `suthep.yml` syntax
364
+ - Check all required fields are present
365
+ - Validate port numbers and domains
366
+
367
+ 3. **Test Components Individually**
368
+ - Test Nginx manually
369
+ - Test Docker containers
370
+ - Test SSL certificates
371
+
372
+ 4. **Check System Resources**
373
+ ```bash
374
+ # Check disk space
375
+ df -h
376
+
377
+ # Check memory
378
+ free -h
379
+
380
+ # Check CPU
381
+ top
382
+ ```
383
+
384
+ ## Prevention
385
+
386
+ To avoid common issues:
387
+
388
+ 1. **Use Staging for Testing**
389
+ ```yaml
390
+ certbot:
391
+ staging: true
392
+ ```
393
+
394
+ 2. **Validate Configuration**
395
+ ```bash
396
+ suthep init # Interactive validation
397
+ ```
398
+
399
+ 3. **Test Before Production**
400
+ - Test on staging environment first
401
+ - Verify all services work individually
402
+ - Test deployment process
403
+
404
+ 4. **Monitor Health Checks**
405
+ - Set appropriate intervals
406
+ - Monitor health check endpoints
407
+ - Set reasonable timeouts
408
+
409
+ ## Next Steps
410
+
411
+ - [Advanced Topics](./08-advanced.md) - Advanced configuration and optimization
412
+ - [Examples](./06-examples.md) - Review working examples
413
+
414
+ ---
415
+
416
+ **Previous:** [Examples](./06-examples.md) | **Next:** [Advanced Topics →](./08-advanced.md)
417
+