git-push-deploy-cli 0.3.1 β†’ 0.6.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 (51) hide show
  1. package/README.md +466 -108
  2. package/dist/commands/config.d.ts.map +1 -1
  3. package/dist/commands/config.js +58 -18
  4. package/dist/commands/config.js.map +1 -1
  5. package/dist/commands/daemon.d.ts +10 -0
  6. package/dist/commands/daemon.d.ts.map +1 -0
  7. package/dist/commands/daemon.js +67 -0
  8. package/dist/commands/daemon.js.map +1 -0
  9. package/dist/commands/deploy.d.ts +1 -1
  10. package/dist/commands/deploy.d.ts.map +1 -1
  11. package/dist/commands/deploy.js +5 -2
  12. package/dist/commands/deploy.js.map +1 -1
  13. package/dist/commands/init.d.ts.map +1 -1
  14. package/dist/commands/init.js +36 -19
  15. package/dist/commands/init.js.map +1 -1
  16. package/dist/commands/install.d.ts.map +1 -1
  17. package/dist/commands/install.js +98 -3
  18. package/dist/commands/install.js.map +1 -1
  19. package/dist/commands/logs.d.ts +1 -0
  20. package/dist/commands/logs.d.ts.map +1 -1
  21. package/dist/commands/logs.js +4 -1
  22. package/dist/commands/logs.js.map +1 -1
  23. package/dist/commands/release.d.ts +1 -1
  24. package/dist/commands/release.d.ts.map +1 -1
  25. package/dist/commands/release.js +162 -8
  26. package/dist/commands/release.js.map +1 -1
  27. package/dist/commands/stage.d.ts.map +1 -1
  28. package/dist/commands/stage.js +4 -3
  29. package/dist/commands/stage.js.map +1 -1
  30. package/dist/commands/status.d.ts.map +1 -1
  31. package/dist/commands/status.js +15 -2
  32. package/dist/commands/status.js.map +1 -1
  33. package/dist/config/types.d.ts +112 -14
  34. package/dist/config/types.d.ts.map +1 -1
  35. package/dist/config/types.js +20 -0
  36. package/dist/config/types.js.map +1 -1
  37. package/dist/index.js +10 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/utils/git.d.ts +8 -0
  40. package/dist/utils/git.d.ts.map +1 -1
  41. package/dist/utils/git.js +22 -0
  42. package/dist/utils/git.js.map +1 -1
  43. package/dist/utils/notifications.d.ts +6 -0
  44. package/dist/utils/notifications.d.ts.map +1 -0
  45. package/dist/utils/notifications.js +188 -0
  46. package/dist/utils/notifications.js.map +1 -0
  47. package/dist/utils/shell.d.ts +4 -0
  48. package/dist/utils/shell.d.ts.map +1 -1
  49. package/dist/utils/shell.js +18 -0
  50. package/dist/utils/shell.js.map +1 -1
  51. package/package.json +1 -1
package/README.md CHANGED
@@ -1,24 +1,223 @@
1
1
  # git-push-deploy-cli (gpd)
2
2
 
3
- Git Push Deploy - A CLI for git-based deployments with PM2 support. Push to deploy Node.js applications via SSH.
3
+ > **Git Push Deploy** - Deploy Node.js applications with a single `git push`. Zero-downtime, multi-server, with Slack/Discord notifications.
4
4
 
5
- ## Features
5
+ [![npm version](https://badge.fury.io/js/git-push-deploy-cli.svg)](https://www.npmjs.com/package/git-push-deploy-cli)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
 
7
- - **Git-based deployment**: Push to bare repo, server hook handles install
8
- - **PM2 integration**: Automatic process restarts with user isolation
9
- - **Lazy initialization**: Deploy repo created on first `gpd stage`
10
- - **SSH orchestration**: Server setup from your dev machine
11
- - **Config-driven**: Define services in `.git-deploy.json`
8
+ ## 🎯 What is GPD?
12
9
 
13
- ## Installation
10
+ GPD is a deployment tool that uses Git's push mechanism to deploy your applications. Push your code, and the server automatically installs dependencies and restarts your app - with zero downtime.
11
+
12
+ ```
13
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
14
+ β”‚ GPD DEPLOYMENT FLOW β”‚
15
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
16
+ β”‚ β”‚
17
+ β”‚ Developer Machine Production Server β”‚
18
+ β”‚ ───────────────── ───────────────── β”‚
19
+ β”‚ β”‚
20
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” git push SSH β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
21
+ β”‚ β”‚ gpd deploy β”‚ ─────────────────────────▢│ Bare Git Repo β”‚ β”‚
22
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
23
+ β”‚ β”‚ β”‚ β”‚
24
+ β”‚ β”‚ 1. Build β”‚ 2. post-receive β”‚
25
+ β”‚ β”‚ 2. Stage artifacts β”‚ hook triggers β”‚
26
+ β”‚ β”‚ 3. Commit β–Ό β”‚
27
+ β”‚ β”‚ 4. Push β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
28
+ β”‚ β”‚ β”‚ gpd install β”‚ β”‚
29
+ β”‚ β”‚ β”‚ ───────────── β”‚ β”‚
30
+ β”‚ β”‚ β”‚ β€’ git checkout β”‚ β”‚
31
+ β”‚ β”‚ β”‚ β€’ npm install β”‚ β”‚
32
+ β”‚ β”‚ β”‚ β€’ pm2 reload β”‚ β”‚
33
+ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
34
+ β”‚ β”‚ β”‚ β”‚
35
+ β”‚ β”‚ 5. Send notification β”‚ 3. App restarted β”‚
36
+ β”‚ β”‚ to Slack/Discord β–Ό β”‚
37
+ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
38
+ β”‚ β–Ό β”‚ App Running β”‚ β”‚
39
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ (zero-downtime)β”‚ β”‚
40
+ β”‚ β”‚ πŸ“± Slack/ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
41
+ β”‚ β”‚ Discord β”‚ β”‚
42
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
43
+ β”‚ β”‚ β”‚
44
+ β”‚ └── Developer receives: "βœ… my-api deployed successfully" β”‚
45
+ β”‚ β”‚
46
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
47
+ ```
48
+
49
+ ## πŸ—οΈ Architecture Overview
50
+
51
+ ### GPD: One Tool, Two Roles (Janus Architecture)
52
+
53
+ GPD is installed **both locally and on the server**. The same CLI serves different purposes depending on where it runs:
54
+
55
+ ```
56
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
57
+ β”‚ GPD JANUS ARCHITECTURE β”‚
58
+ β”‚ (Same CLI, Two Roles) β”‚
59
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
60
+ β”‚ β”‚
61
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
62
+ β”‚ β”‚ LOCAL (Dev Machine) β”‚ β”‚ SERVER (Production) β”‚ β”‚
63
+ β”‚ β”‚ ════════════════════ β”‚ β”‚ ════════════════════ β”‚ β”‚
64
+ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
65
+ β”‚ β”‚ $ gpd deploy β”‚ β”‚ $ gpd install β”‚ β”‚
66
+ β”‚ β”‚ $ gpd init β”‚ β”‚ (called by git hook) β”‚ β”‚
67
+ β”‚ β”‚ $ gpd stage β”‚ β”‚ β”‚ β”‚
68
+ β”‚ β”‚ $ gpd release β”‚ β”‚ β”‚ β”‚
69
+ β”‚ β”‚ $ gpd rollback β”‚ β”‚ β”‚ β”‚
70
+ β”‚ β”‚ $ gpd config β”‚ β”‚ β”‚ β”‚
71
+ β”‚ β”‚ $ gpd logs (via SSH) β”‚ β”‚ β”‚ β”‚
72
+ β”‚ β”‚ $ gpd daemon (via SSH) β”‚ β”‚ β”‚ β”‚
73
+ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
74
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
75
+ β”‚ β”‚ β–² β”‚
76
+ β”‚ β”‚ β”‚ β”‚
77
+ β”‚ β”‚ 1. git push β”‚ 2. post-receive β”‚
78
+ β”‚ β”‚ (artifacts) β”‚ hook calls β”‚
79
+ β”‚ β”‚ β”‚ gpd install β”‚
80
+ β”‚ β–Ό β”‚ β”‚
81
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
82
+ β”‚ β”‚ β”‚ β”‚
83
+ β”‚ β”‚ #!/bin/bash β”‚ β”‚
84
+ β”‚ β”‚ # post-receive hook (generated by gpd init) β”‚ β”‚
85
+ β”‚ β”‚ β”‚ β”‚
86
+ β”‚ β”‚ gpd install my-service -c /opt/app/.git-deploy.json β”‚ β”‚
87
+ β”‚ β”‚ β–² β”‚ β”‚
88
+ β”‚ β”‚ β”‚ β”‚ β”‚
89
+ β”‚ β”‚ └── GPD calls ITSELF on the server! β”‚ β”‚
90
+ β”‚ β”‚ β”‚ β”‚
91
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
92
+ β”‚ β”‚
93
+ β”‚ Installation: β”‚
94
+ β”‚ ───────────── β”‚
95
+ β”‚ β”‚
96
+ β”‚ # On dev machine # On server β”‚
97
+ β”‚ npm install -g git-push-deploy-cli npm install -g git-push-deploy-cli β”‚
98
+ β”‚ β”‚
99
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
100
+ ```
101
+
102
+ ### Deployment Architecture
103
+
104
+ ```
105
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
106
+ β”‚ WORKSPACE STRUCTURE β”‚
107
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
108
+ β”‚ β”‚
109
+ β”‚ Your Workspace (local) β”‚
110
+ β”‚ ────────────────────── β”‚
111
+ β”‚ workspace/ β”‚
112
+ β”‚ β”œβ”€β”€ .git-deploy.json ◄── GPD configuration β”‚
113
+ β”‚ β”‚ β”‚
114
+ β”‚ └── my-api/ (your project) β”‚
115
+ β”‚ β”œβ”€β”€ src/ source code β”‚
116
+ β”‚ β”œβ”€β”€ dist/ build output β”‚
117
+ β”‚ β”œβ”€β”€ package.json β”‚
118
+ β”‚ β”‚ β”‚
119
+ β”‚ └── deploy/ ◄── GPD creates this β”‚
120
+ β”‚ β”œβ”€β”€ staging/ deploy repo for staging β”‚
121
+ β”‚ β”‚ β”œβ”€β”€ .git ────────────────────┐ β”‚
122
+ β”‚ β”‚ β”œβ”€β”€ dist/ β”‚ points to β”‚
123
+ β”‚ β”‚ └── package.json β”‚ bare repo β”‚
124
+ β”‚ β”‚ β”‚ β”‚
125
+ β”‚ └── production/ β”‚ β”‚
126
+ β”‚ β”œβ”€β”€ .git ────────────────────┼───┐ β”‚
127
+ β”‚ β”œβ”€β”€ dist/ β”‚ β”‚ β”‚
128
+ β”‚ └── package.json β”‚ β”‚ β”‚
129
+ β”‚ β”‚ β”‚ β”‚
130
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
131
+ β”‚ β”‚ β”‚ β”‚
132
+ β”‚ Server (remote via SSH) β”‚ β”‚ β”‚
133
+ β”‚ ─────────────────────── β”‚ β”‚ β”‚
134
+ β”‚ β–Ό β–Ό β”‚
135
+ β”‚ /git/deploy/ Bare Git Repositories β”‚
136
+ β”‚ β”œβ”€β”€ staging/my-api/ (receive pushes) β”‚
137
+ β”‚ β”‚ └── hooks/post-receive triggers gpd install β”‚
138
+ β”‚ β”‚ β”‚
139
+ β”‚ └── production/my-api/ β”‚
140
+ β”‚ └── hooks/post-receive β”‚
141
+ β”‚ β”‚
142
+ β”‚ /opt/apps/ Application Directories β”‚
143
+ β”‚ β”œβ”€β”€ staging/my-api/ (where code runs) β”‚
144
+ β”‚ β”‚ β”œβ”€β”€ dist/ β”‚
145
+ β”‚ β”‚ β”œβ”€β”€ package.json β”‚
146
+ β”‚ β”‚ β”œβ”€β”€ node_modules/ β”‚
147
+ β”‚ β”‚ └── .env ◄── generated from config β”‚
148
+ β”‚ β”‚ β”‚
149
+ β”‚ └── production/my-api/ β”‚
150
+ β”‚ β”œβ”€β”€ dist/ β”‚
151
+ β”‚ └── ... β”‚
152
+ β”‚ β”‚
153
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
154
+ ```
155
+
156
+ ### Runtime Architecture
157
+
158
+ ```
159
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
160
+ β”‚ RUNTIME / HOSTING β”‚
161
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
162
+ β”‚ β”‚
163
+ β”‚ Server β”‚
164
+ β”‚ ────── β”‚
165
+ β”‚ β”‚
166
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
167
+ β”‚ β”‚ Process Manager (PM2 or GPDD) β”‚ β”‚
168
+ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚
169
+ β”‚ β”‚ β”‚ β”‚
170
+ β”‚ β”‚ PM2 Mode GPDD Mode (Zero-Downtime) β”‚ β”‚
171
+ β”‚ β”‚ ──────── ───────────────────────── β”‚ β”‚
172
+ β”‚ β”‚ β”‚ β”‚
173
+ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
174
+ β”‚ β”‚ β”‚ PM2 β”‚ β”‚ GPDD Master β”‚ β”‚ β”‚
175
+ β”‚ β”‚ β”‚ Daemon β”‚ β”‚ (cluster manager) β”‚ β”‚ β”‚
176
+ β”‚ β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
177
+ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
178
+ β”‚ β”‚ β”‚ manages β”‚ manages β”‚ β”‚
179
+ β”‚ β”‚ β–Ό β–Ό β”‚ β”‚
180
+ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
181
+ β”‚ β”‚ β”‚ App β”‚ β”‚ Worker 1 Worker 2 β”‚ β”‚ β”‚
182
+ β”‚ β”‚ β”‚ Process β”‚ β”‚ Worker 3 Worker 4 β”‚ β”‚ β”‚
183
+ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
184
+ β”‚ β”‚ β”‚ β”‚
185
+ β”‚ β”‚ restart on crash β€’ Rolling restart β”‚ β”‚
186
+ β”‚ β”‚ cluster mode β€’ Zero-downtime reload β”‚ β”‚
187
+ β”‚ β”‚ log management β€’ Built-in clustering β”‚ β”‚
188
+ β”‚ β”‚ β”‚ β”‚
189
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
190
+ β”‚ β”‚
191
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
192
+ β”‚ β”‚ Port 3000 β”‚ β”‚ Port 3001 β”‚ β”‚ Port 3002 β”‚ β”‚
193
+ β”‚ β”‚ my-api-staging β”‚ β”‚ my-api-prod β”‚ β”‚ other-service β”‚ β”‚
194
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
195
+ β”‚ β”‚ β”‚ β”‚ β”‚
196
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
197
+ β”‚ β”‚ β”‚
198
+ β”‚ β–Ό β”‚
199
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
200
+ β”‚ β”‚ Reverse Proxy β”‚ β”‚
201
+ β”‚ β”‚ (nginx/caddy) β”‚ β”‚
202
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
203
+ β”‚ β”‚ β”‚
204
+ β”‚ β–Ό β”‚
205
+ β”‚ Internet β”‚
206
+ β”‚ β”‚
207
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
208
+ ```
209
+
210
+ ## ⚑ Quick Start
211
+
212
+ ### Installation
14
213
 
15
214
  ```bash
16
215
  npm install -g git-push-deploy-cli
17
216
  ```
18
217
 
19
- ## Quick Start
218
+ ### 1. Configure your service
20
219
 
21
- ### 1. Create `.git-deploy.json` in your workspace root:
220
+ Create `.git-deploy.json` in your workspace root:
22
221
 
23
222
  ```json
24
223
  {
@@ -26,141 +225,300 @@ npm install -g git-push-deploy-cli
26
225
  "my-api-staging": {
27
226
  "sourceDir": "my-api",
28
227
  "deployRepo": "deploy/staging",
29
- "artifacts": ["dist/index.js", "package.json", "ecosystem.config.cjs"],
228
+ "artifacts": ["dist", "package.json"],
30
229
  "processManager": "pm2",
31
230
  "processName": "my-api-staging",
32
- "pm2Home": "/opt/myapp/.pm2",
33
- "pm2User": "myapp",
34
231
  "environment": "staging",
35
- "env": {
36
- "PORT": 5000,
37
- "NODE_ENV": "staging"
38
- },
39
232
  "server": {
40
- "host": "user@myserver",
41
- "sshOptions": "-p 22",
42
- "targetDir": "/opt/myapp/staging/my-api",
43
- "bareRepo": "/git/deploy-myapp/staging/my-api",
44
- "group": "deploy-myapp"
233
+ "host": "deploy@myserver.com",
234
+ "targetDir": "/opt/apps/staging/my-api",
235
+ "bareRepo": "/git/deploy/staging/my-api"
45
236
  }
46
237
  }
47
238
  }
48
239
  }
49
240
  ```
50
241
 
51
- ### 2. Initialize server (once per service)
242
+ ### 2. Initialize server (once)
52
243
 
53
244
  ```bash
54
245
  gpd init my-api-staging
55
246
  ```
56
247
 
57
- This creates via SSH:
58
- - Bare git repository at `/git/deploy-myapp/staging/my-api`
59
- - Target directory at `/opt/myapp/staging/my-api`
60
- - Post-receive hook that calls `gpd install`
61
-
62
248
  ### 3. Deploy
63
249
 
64
250
  ```bash
65
251
  gpd deploy my-api-staging
66
252
  ```
67
253
 
68
- This:
69
- 1. Creates deploy repo (if needed) at `my-api/deploy/staging/`
70
- 2. Copies build artifacts to deploy repo
71
- 3. Commits and pushes to bare repo on server
72
- 4. Server hook: `git checkout && npm install && pm2 restart`
254
+ That's it! Your app is now running on the server.
73
255
 
74
- ## Commands
256
+ ## πŸ“– Commands
75
257
 
76
- | Command | Description |
77
- |---------|-------------|
78
- | `gpd status` | Show all configured services |
79
- | `gpd stage <service>` | Copy build artifacts to deploy repo |
80
- | `gpd release <service>` | Commit and push deploy repo |
81
- | `gpd deploy <service>` | Stage + release (hook handles install) |
82
- | `gpd init <service>` | Initialize server (bare repo, target dir, hook) |
83
- | `gpd install <service>` | Server-side install (called by hook) |
84
- | `gpd logs <service>` | Show PM2 logs from server via SSH |
258
+ ```
259
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
260
+ β”‚ GPD COMMANDS β”‚
261
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
262
+ β”‚ Command β”‚ Description β”‚
263
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
264
+ β”‚ gpd status β”‚ Show all configured services β”‚
265
+ β”‚ gpd config β”‚ Interactive configuration wizard β”‚
266
+ β”‚ gpd init β”‚ Initialize server (bare repo, target dir, hooks) β”‚
267
+ β”‚ gpd deploy β”‚ Full deployment (stage + release) β”‚
268
+ β”‚ gpd stage β”‚ Copy build artifacts to deploy repo β”‚
269
+ β”‚ gpd release β”‚ Commit and push to server β”‚
270
+ β”‚ gpd rollback β”‚ Rollback to previous version β”‚
271
+ β”‚ gpd logs β”‚ Show application logs from server β”‚
272
+ β”‚ gpd daemon β”‚ Manage GPDD process (start/stop/status/logs) β”‚
273
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
274
+ β”‚ Options β”‚ β”‚
275
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
276
+ β”‚ -m, --message β”‚ Custom commit message β”‚
277
+ β”‚ -n, --lines β”‚ Number of log lines (default: 50) β”‚
278
+ β”‚ -f, --follow β”‚ Follow logs in real-time β”‚
279
+ β”‚ --dry-run β”‚ Preview changes without executing β”‚
280
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
281
+ ```
85
282
 
86
- ## Options
283
+ ## πŸ”§ Features
87
284
 
88
- ```bash
89
- gpd deploy my-api -m "custom commit message"
90
- gpd deploy my-api --skip-push # Only stage, do not push
91
- gpd logs my-api -f # Follow logs
92
- gpd logs my-api -n 100 # Show last 100 lines
285
+ ### Multi-Server Deployment
286
+
287
+ Deploy to multiple servers simultaneously:
288
+
289
+ ```json
290
+ {
291
+ "services": {
292
+ "my-api-prod": {
293
+ "servers": [
294
+ { "name": "primary", "host": "prod1.example.com", "targetDir": "/opt/app" },
295
+ { "name": "replica", "host": "prod2.example.com", "targetDir": "/opt/app" }
296
+ ]
297
+ }
298
+ }
299
+ }
93
300
  ```
94
301
 
95
- ## Config Reference
302
+ ```
303
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
304
+ β”‚ MULTI-SERVER DEPLOYMENT β”‚
305
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
306
+ β”‚ β”‚
307
+ β”‚ gpd deploy my-api-prod β”‚
308
+ β”‚ β”‚ β”‚
309
+ β”‚ β”‚ β”‚
310
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
311
+ β”‚ β”‚ β”‚ β”‚ β”‚
312
+ β”‚ β–Ό β–Ό β–Ό β”‚
313
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
314
+ β”‚ β”‚ Server 1 β”‚ β”‚ Server 2 β”‚ β”‚ Server 3 β”‚ β”‚
315
+ β”‚ β”‚ (primary)β”‚ β”‚ (replica)β”‚ β”‚ (replica)β”‚ β”‚
316
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
317
+ β”‚ β”‚ β”‚ β”‚ β”‚
318
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
319
+ β”‚ β”‚ β”‚
320
+ β”‚ β–Ό β”‚
321
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
322
+ β”‚ β”‚ Load Balancer β”‚ β”‚
323
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
324
+ β”‚ β”‚
325
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
326
+ ```
327
+
328
+ ### Deployment Hooks
329
+
330
+ Run custom scripts before/after deployment:
331
+
332
+ ```json
333
+ {
334
+ "hooks": {
335
+ "preDeploy": ["npm run lint", "npm test"],
336
+ "postDeploy": ["npx prisma migrate deploy"],
337
+ "postDeployLocal": ["echo 'Deployed!'"]
338
+ }
339
+ }
340
+ ```
341
+
342
+ ```
343
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
344
+ β”‚ DEPLOYMENT HOOKS β”‚
345
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
346
+ β”‚ β”‚
347
+ β”‚ LOCAL (Developer Machine) SERVER β”‚
348
+ β”‚ ───────────────────────── ────── β”‚
349
+ β”‚ β”‚
350
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
351
+ β”‚ β”‚ 1. preDeploy hooks β”‚ ◄── npm run lint, npm test β”‚
352
+ β”‚ β”‚ (local) β”‚ β”‚
353
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
354
+ β”‚ β”‚ β”‚
355
+ β”‚ β–Ό β”‚
356
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
357
+ β”‚ β”‚ 2. git push β”‚ ──────────────▢│ 3. post-receive β”‚ β”‚
358
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ hook β”‚ β”‚
359
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
360
+ β”‚ β”‚ β”‚
361
+ β”‚ β–Ό β”‚
362
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
363
+ β”‚ β”‚ 4. gpd install β”‚ β”‚
364
+ β”‚ β”‚ β€’ git checkout β”‚ β”‚
365
+ β”‚ β”‚ β€’ npm install β”‚ β”‚
366
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
367
+ β”‚ β”‚ β”‚
368
+ β”‚ β–Ό β”‚
369
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
370
+ β”‚ β”‚ 5. postDeploy hooks β”‚ β”‚
371
+ β”‚ β”‚ (server) β”‚ β”‚
372
+ β”‚ β”‚ e.g. prisma β”‚ β”‚
373
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
374
+ β”‚ β”‚ β”‚
375
+ β”‚ β–Ό β”‚
376
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
377
+ β”‚ β”‚ 6. Process restart β”‚ β”‚
378
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ (PM2/GPDD) β”‚ β”‚
379
+ β”‚ β”‚ 7. postDeployLocal β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
380
+ β”‚ β”‚ hooks β”‚ notification β”‚
381
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
382
+ β”‚ β”‚
383
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
384
+ ```
385
+
386
+ ### Notifications (Slack, Discord, Webhook)
387
+
388
+ Get notified on every deployment:
389
+
390
+ ```json
391
+ {
392
+ "notifications": {
393
+ "slack": {
394
+ "webhookUrl": "https://hooks.slack.com/services/xxx",
395
+ "channel": "#deployments"
396
+ },
397
+ "discord": {
398
+ "webhookUrl": "https://discord.com/api/webhooks/xxx"
399
+ },
400
+ "webhook": {
401
+ "url": "https://your-api.com/deploy-hook",
402
+ "headers": { "Authorization": "Bearer xxx" }
403
+ }
404
+ }
405
+ }
406
+ ```
407
+
408
+ ### Process Managers
409
+
410
+ GPD supports multiple process managers:
411
+
412
+ | Manager | Description | Use Case |
413
+ |---------|-------------|----------|
414
+ | `pm2` | Industry standard, feature-rich | Production, logging, monitoring |
415
+ | `gpdd` | Built-in, zero-downtime | Simple apps, zero-config |
416
+ | `systemd` | Linux system service | Server integration |
417
+
418
+ ### Zero-Downtime with GPDD
419
+
420
+ ```
421
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
422
+ β”‚ GPDD ZERO-DOWNTIME RELOAD β”‚
423
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
424
+ β”‚ β”‚
425
+ β”‚ Before Reload After gpdd reload β”‚
426
+ β”‚ ───────────── ───────────────── β”‚
427
+ β”‚ β”‚
428
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
429
+ β”‚ β”‚ Master β”‚ β”‚ Master β”‚ β”‚
430
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
431
+ β”‚ β”‚ β”‚ β”‚
432
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β” β”‚
433
+ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
434
+ β”‚ β–Ό β–Ό β–Ό β–Ό β”‚
435
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”‚
436
+ β”‚ β”‚ W1 β”‚ β”‚ W2 β”‚ β”‚ W1 β”‚ β”‚ W2 β”‚ β”‚
437
+ β”‚ β”‚ OLD β”‚ β”‚ OLD β”‚ β”‚ NEW β”‚ β”‚ NEW β”‚ β”‚
438
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β”‚
439
+ β”‚ β”‚
440
+ β”‚ Rolling restart: β”‚
441
+ β”‚ 1. Start new W1 β”‚
442
+ β”‚ 2. Stop old W1 (after ready) β”‚
443
+ β”‚ 3. Start new W2 β”‚
444
+ β”‚ 4. Stop old W2 β”‚
445
+ β”‚ β”‚
446
+ β”‚ βœ“ No dropped connections β”‚
447
+ β”‚ β”‚
448
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
449
+ ```
450
+
451
+ ## πŸ“‹ Full Configuration Reference
96
452
 
97
453
  ```typescript
98
454
  interface ServiceConfig {
99
- sourceDir: string; // Project directory (e.g., "my-api")
100
- deployRepo: string; // Deploy repo path, relative to sourceDir
101
- artifacts: string[]; // Files/dirs to copy
102
- processManager: 'pm2'; // Process manager type
103
- processName: string; // PM2 process name
104
- pm2Home?: string; // PM2_HOME on server
105
- pm2User?: string; // User to run PM2 as (sudo -u)
106
- environment?: string; // staging | production
107
- env?: Record<string, any>; // Environment variables for .env file
108
- server: {
109
- host: string; // SSH host (user@hostname)
110
- sshOptions?: string; // SSH options (e.g., "-p 6771 -4")
111
- targetDir: string; // Target directory on server
112
- bareRepo: string; // Bare repo path on server
113
- group?: string; // Unix group for permissions
455
+ // Source & Deploy
456
+ sourceDir: string; // Project directory (e.g., "my-api")
457
+ deployRepo: string; // Deploy repo path (e.g., "deploy/staging")
458
+ artifacts: string[]; // Files to deploy (e.g., ["dist", "package.json"])
459
+
460
+ // Process Manager
461
+ processManager?: 'pm2' | 'gpdd' | 'systemd';
462
+ processName: string; // Process name
463
+ pm2Home?: string; // PM2_HOME directory
464
+ pm2User?: string; // User for PM2 (sudo -u)
465
+ gpddWorkers?: number; // GPDD worker count (0 = auto)
466
+ gpddEntryPoint?: string; // Entry point (default: dist/index.js)
467
+
468
+ // Environment
469
+ environment?: 'production' | 'staging' | 'development';
470
+ env?: Record<string, string | number | boolean>;
471
+
472
+ // Server (single)
473
+ server?: {
474
+ host: string; // SSH host (user@hostname)
475
+ sshOptions?: string; // SSH options (e.g., "-p 22")
476
+ targetDir: string; // Where code runs
477
+ bareRepo: string; // Git bare repo path
478
+ group?: string; // Unix group
479
+ name?: string; // Display name
480
+ };
481
+
482
+ // Servers (multi)
483
+ servers?: ServerConfig[]; // Multiple servers
484
+
485
+ // Hooks
486
+ hooks?: {
487
+ preDeploy?: string[]; // Run locally before push
488
+ postDeploy?: string[]; // Run on server after install
489
+ postDeployLocal?: string[]; // Run locally after success
490
+ };
491
+
492
+ // Notifications
493
+ notifications?: {
494
+ slack?: { webhookUrl: string; channel?: string; };
495
+ discord?: { webhookUrl: string; };
496
+ webhook?: { url: string; headers?: Record<string, string>; };
114
497
  };
115
498
  }
116
499
  ```
117
500
 
118
- ## Architecture
501
+ ## πŸ› οΈ Server Prerequisites
119
502
 
120
- ```
121
- Workspace Server
122
- ───────── ──────
123
- my-api/
124
- β”œβ”€β”€ src/ /git/deploy-myapp/staging/my-api/
125
- β”œβ”€β”€ dist/ └── hooks/post-receive
126
- └── deploy/ ↓
127
- └── staging/ /opt/myapp/staging/my-api/
128
- β”œβ”€β”€ .git β†’ ssh://... β”œβ”€β”€ dist/index.js
129
- β”œβ”€β”€ dist/ β”œβ”€β”€ package.json
130
- └── package.json β”œβ”€β”€ node_modules/
131
- └── .env (generated)
503
+ - **Node.js** (18+ recommended)
504
+ - **Git**
505
+ - **SSH access** from dev machine
506
+ - **PM2** or **GPDD** (installed globally)
507
+ - **GPD CLI** (installed globally on server)
508
+
509
+ ```bash
510
+ # On server
511
+ npm install -g pm2 git-push-deploy-cli
512
+ # Or for GPDD
513
+ npm install -g git-push-deploy-daemon git-push-deploy-cli
132
514
  ```
133
515
 
134
- ## Workflow
516
+ ## πŸ“š More Documentation
135
517
 
136
- ```
137
- Dev Machine Server
138
- ─────────── ──────
139
- gpd deploy my-api-staging
140
- β”‚
141
- β”œβ”€ gpd stage
142
- β”‚ └─ Copy artifacts β†’ my-api/deploy/staging/
143
- β”‚
144
- └─ gpd release
145
- └─ git push ───────────────→ /git/deploy-myapp/staging/my-api
146
- β”‚
147
- └─ post-receive hook:
148
- gpd install my-api-staging
149
- β”‚
150
- β”œβ”€ git checkout -f
151
- β”œβ”€ .env generation
152
- β”œβ”€ npm install --omit=dev
153
- └─ pm2 restart
154
- ```
155
-
156
- ## Server Prerequisites
157
-
158
- - Node.js + npm
159
- - PM2 (`npm install -g pm2`)
160
- - gpd CLI (`npm install -g git-push-deploy-cli`)
161
- - SSH access from dev machine
162
- - Git
163
-
164
- ## License
518
+ - [Git-Based Deployment Guide](../docs/git-based-deployment.md)
519
+ - [PM2 Process Management](../docs/pm2-process-management.md)
520
+ - [GPDD Daemon Documentation](../git-push-deploy-daemon/README.md)
521
+
522
+ ## πŸ“„ License
165
523
 
166
524
  MIT