magicserve 1.2.6 → 2.0.2

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 (4) hide show
  1. package/README.es.md +24 -17
  2. package/README.md +25 -17
  3. package/package.json +2 -2
  4. package/run.sh +49 -100
package/README.es.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  *[Read in English](README.md)*
4
4
 
5
- Magicserve es una herramienta CLI para gestionar entornos de desarrollo web locales. Su objetivo es iniciar, detener y manejar el estado de múltiples servidores locales (`node` y `php`) al mismo tiempo, y automáticamente levantar un Reverse Proxy (Nginx) y generar certificados SSL vía `mkcert` para asignarle un dominio dinámico (ej. `tu-proyecto.test`).
5
+ Magicserve es una herramienta CLI para gestionar entornos de desarrollo web locales. Levanta automáticamente un Reverse Proxy (Nginx) con HTTPS para múltiples servicios locales a la vez, genera certificados SSL vía `mkcert` y le asigna a cada uno un dominio dinámico (ej. `tu-proyecto.test`), además de URLs públicas opcionales vía `localtunnel`.
6
+
7
+ > **Tú levantas tus propios servidores.** Magicserve **no** inicia ni detiene tus apps. Tú levantas lo que quieras (Node, PHP, Python, Go, …) en los puertos que listes en `magicserve.json`, y Magicserve enlaza el dominio HTTPS, el certificado y el túnel a ese puerto.
6
8
 
7
9
  ## Requisitos
8
10
 
@@ -45,20 +47,16 @@ Este comando creará automáticamente un archivo base llamado **`magicserve.json
45
47
 
46
48
  ### Archivo de configuración: `magicserve.json`
47
49
 
48
- Tu directorio central gestiona y levanta las aplicaciones referenciadas dentro del **`magicserve.json`**. Su estructura es así de sencilla:
50
+ Tu directorio central mapea dominios a los puertos locales de las apps que mismo levantas. Su estructura es así de sencilla:
49
51
 
50
52
  ```json
51
53
  [
52
54
  {
53
- "path": "../tu-proyecto-frontal",
54
55
  "domain": "tu-proyecto.test",
55
- "type": "node",
56
56
  "port": 3000
57
57
  },
58
58
  {
59
- "path": "../tu-api-backend",
60
59
  "domain": "api.tu-proyecto.test",
61
- "type": "php",
62
60
  "port": 3001,
63
61
  "tunnel": "mi-super-api-dev"
64
62
  }
@@ -66,13 +64,11 @@ Tu directorio central gestiona y levanta las aplicaciones referenciadas dentro d
66
64
  ```
67
65
 
68
66
  **Propiedades:**
69
- - **`path`**: Ruta relativa o absoluta hacia el directorio del proyecto donde se deberá correr el servidor.
70
67
  - **`domain`**: El dominio de desarrollo local que se enlazará automáticamente (eg. `*.test`).
71
- - **`type`**: `node` (Correrá usando `npm run dev`) o `php` (Correrá el built-in server usando `php -S`).
72
- - **`port`**: El puerto interno que el servicio ocupará.
73
- - **`tunnel`**: *(Opcional)* Subdominio para enlazar puerto interno y exponerlo a internet público a través de `localtunnel` (Ej. webhooks de Mercado Libre o pruebas móviles).
68
+ - **`port`**: El puerto local donde está escuchando **tu** servidor. Magicserve hace proxy del dominio a `localhost:<port>`; tú eres responsable de levantar ese servidor.
69
+ - **`tunnel`**: *(Opcional)* Subdominio para exponer tu puerto a internet público a través de `localtunnel` (Ej. webhooks de Mercado Libre o pruebas móviles). Usa `true` para un subdominio aleatorio.
74
70
 
75
- Una vez configurado o modificado a tu gusto, utiliza los comandos de control.
71
+ Una vez configurado a tu gusto, levanta tus propios servidores en esos puertos y utiliza los comandos de control.
76
72
 
77
73
  ## Comandos disponibles
78
74
 
@@ -88,8 +84,8 @@ flowchart TD
88
84
  subgraph Tu Computadora Local
89
85
  Nginx(Nginx Proxy Inverso SSL)
90
86
  LT(LocalTunnel Túnel Reverso)
91
- Node((Servidor Node\nEj. 3000))
92
- PHP((Servidor PHP\nEj. 3001))
87
+ Node((Tu Servidor\nEj. 3000))
88
+ PHP((Tu Servidor\nEj. 3001))
93
89
  end
94
90
 
95
91
  Dev -- "https://tu-proyecto.test" --> Nginx
@@ -100,16 +96,27 @@ flowchart TD
100
96
  LT -- "Túnel" --> PHP
101
97
  ```
102
98
 
99
+ > Magicserve gestiona las partes de infraestructura (proxy Nginx, SSL, hosts, túnel). Los servidores detrás de los puertos los inicias y detienes tú.
103
100
 
104
101
  Dentro del directorio donde está tu `magicserve.json`, dispones de los siguientes comandos mágicos:
105
102
 
106
- - **`magicserve start`**: Inicia todos los servicios del `magicserve.json` en los puertos definidos, genera certificados SSL dinámicos de ser necesario y configura Nginx.
107
- - **`magicserve stop`**: Detiene ordenadamente los servicios activos mencionados de tu `magicserve.json`.
108
- - **`magicserve status`**: Te muestra en terminal cuáles de tus proyectos están activos actualmente y cuál es su PID.
109
- - **`magicserve stopall`**: Comando de emergencia. Busca y destruye TODOS los demonios, configuraciones temporales nginx relacionadas, certificados, puertos y purga todas las entradas de localhost customizadas en todo el sistema, restaurando tu computadora.
103
+ - **`magicserve start`**: Para cada dominio genera el certificado SSL si hace falta, agrega la entrada en `/etc/hosts`, escribe el proxy HTTPS de Nginx hacia `localhost:<port>` y abre los túneles configurados. (Levanta tus servidores antes o después — Magicserve no los inicia.)
104
+ - **`magicserve stop`**: Quita los proxys de Nginx y las entradas de `/etc/hosts` y cierra los túneles de los dominios de tu `magicserve.json`. Tus servidores siguen corriendo.
105
+ - **`magicserve status`**: Te muestra si hay un servidor escuchando en el puerto de cada dominio, más el estado y la URL pública de los túneles.
106
+ - **`magicserve stopall`**: Comando de emergencia. Destruye TODAS las configuraciones de proxy de Nginx, túneles, certificados SSL y entradas custom de `localhost` en todo el sistema, restaurando tu computadora. (Ya no mata tus servidores de apps — esos los gestionas tú.)
110
107
 
111
108
  ---
112
109
 
110
+ ### Novedades en v2.0.0 🔌 (Breaking)
111
+
112
+ - **Tú levantas tus propios servidores.** Magicserve ya no inicia procesos `node`/`php` — solo configura el proxy HTTPS de Nginx, el certificado SSL, la entrada en `/etc/hosts` y el túnel opcional apuntando al puerto que tú levantas (funciona con **cualquier** stack: Node, PHP, Python, Go, …).
113
+ - **Config más simple.** `magicserve.json` ahora solo lleva `domain` + `port` (+ `tunnel` opcional). Se eliminaron las propiedades `path` y `type`.
114
+ - **`stop` no afecta a tus apps.** Solo retira el proxy y los túneles; tus servidores siguen corriendo.
115
+ - **`status` revisa el puerto.** Ahora reporta si hay algo escuchando en cada puerto (vía `lsof`) en lugar de rastrear el PID de un servidor.
116
+ - **`stopall` ya no mata tus servidores de apps** (esos los gestionas tú); sigue purgando todos los proxys, túneles, certificados y entradas custom de `hosts`.
117
+
118
+ > **Migrar desde v1.x:** elimina `path` y `type` de cada entrada de tu `magicserve.json`, y levanta tus servidores tú mismo antes/después de ejecutar `magicserve start`.
119
+
113
120
  ### Novedades en v1.2.0 🚇
114
121
 
115
122
  - **Localtunnel Integrado**: Expón de forma permanente y automática puertos de tu API al internet vía la nueva propiedad `tunnel` en el config json para recibir **Webhooks** de terceros (Mercado Libre, Stripe, etc).
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  *[Leer en Español](README.es.md)*
4
4
 
5
- Magicserve is a CLI tool for managing local web development environments. Its goal is to start, stop, and manage the state of multiple local servers (`node` and `php`) simultaneously, automatically set up a Reverse Proxy (Nginx), and generate SSL certificates via `mkcert` to assign them a dynamic local domain (e.g. `your-project.test`).
5
+ Magicserve is a CLI tool for managing local web development environments. It automatically sets up a Reverse Proxy (Nginx) with HTTPS for multiple local services at once, generates SSL certificates via `mkcert`, and assigns each a dynamic local domain (e.g. `your-project.test`) — plus optional public `localtunnel` URLs.
6
+
7
+ > **You run your own servers.** Magicserve does **not** start or stop your apps. Launch whatever you want (Node, PHP, Python, Go, …) on the ports listed in `magicserve.json`, and Magicserve wires the HTTPS domain, certificate, and tunnel to that port.
6
8
 
7
9
  ## Requirements
8
10
 
@@ -45,20 +47,16 @@ This command will automatically create a base **`magicserve.json`** file in the
45
47
 
46
48
  ### Configuration File: `magicserve.json`
47
49
 
48
- Your central directory manages and starts the applications referenced within the **`magicserve.json`**. Its structure is this simple:
50
+ Your central directory maps domains to the local ports of the apps you run yourself. Its structure is this simple:
49
51
 
50
52
  ```json
51
53
  [
52
54
  {
53
- "path": "../your-frontend-project",
54
55
  "domain": "your-project.test",
55
- "type": "node",
56
56
  "port": 3000
57
57
  },
58
58
  {
59
- "path": "../your-backend-api",
60
59
  "domain": "api.your-project.test",
61
- "type": "php",
62
60
  "port": 3001,
63
61
  "tunnel": "my-cool-api-dev"
64
62
  }
@@ -66,13 +64,11 @@ Your central directory manages and starts the applications referenced within the
66
64
  ```
67
65
 
68
66
  **Properties:**
69
- - **`path`**: Relative or absolute path to the project's directory where the server should run.
70
67
  - **`domain`**: The local development domain that will be automatically mapped (e.g. `*.test`).
71
- - **`type`**: `node` (Runs using `npm run dev`) or `php` (Runs the PHP built-in server using `php -S`).
72
- - **`port`**: The internal port the service will use.
73
- - **`tunnel`**: *(Optional)* Subdomain to securely expose your internal port to the public internet via `localtunnel` (Great for testing third-party Webhooks like Mercado Libre or local mobile testing).
68
+ - **`port`**: The local port where **your** server is listening. Magicserve proxies the domain to `localhost:<port>`; you are responsible for starting that server.
69
+ - **`tunnel`**: *(Optional)* Subdomain to securely expose your port to the public internet via `localtunnel` (Great for testing third-party Webhooks like Mercado Libre or local mobile testing). Use `true` for a random subdomain.
74
70
 
75
- Once configured or modified to your liking, you can use the control commands.
71
+ Once configured to your liking, start your own servers on those ports, then use the control commands below.
76
72
 
77
73
  ## Available Commands
78
74
 
@@ -88,8 +84,8 @@ flowchart TD
88
84
  subgraph Your Local Machine
89
85
  Nginx(Nginx Reverse Proxy with HTTPS)
90
86
  LT(LocalTunnel Reverse Tunnel)
91
- Node((Node Server\ne.g. 3000))
92
- PHP((PHP Server\ne.g. 3001))
87
+ Node((Your Server\ne.g. 3000))
88
+ PHP((Your Server\ne.g. 3001))
93
89
  end
94
90
 
95
91
  Dev -- "https://your-project.test" --> Nginx
@@ -100,15 +96,27 @@ flowchart TD
100
96
  LT -- "Tunnel" --> PHP
101
97
  ```
102
98
 
99
+ > Magicserve manages the dashed parts (Nginx proxy, SSL, hosts, tunnel). The servers behind the ports are started and stopped by you.
100
+
103
101
  Within the directory where your `magicserve.json` is located, you have the following magic commands available:
104
102
 
105
- - **`magicserve start`**: Starts all services declared in `magicserve.json` on the defined ports, generates dynamic SSL certificates if necessary, and configures Nginx.
106
- - **`magicserve stop`**: Orderly stops the active services mentioned in your `magicserve.json`.
107
- - **`magicserve status`**: Shows a terminal output of which projects are currently active and their PIDs.
108
- - **`magicserve stopall`**: Emergency command. Finds and destroys ALL active daemons, related Nginx configurations, certificates, processes, and purges all custom localhost entries system-wide, restoring your computer's clean state.
103
+ - **`magicserve start`**: For every domain, generates an SSL certificate if needed, adds the `/etc/hosts` entry, writes the Nginx HTTPS proxy to `localhost:<port>`, and opens any configured tunnels. (Start your own servers first or afterward — Magicserve does not launch them.)
104
+ - **`magicserve stop`**: Removes the Nginx proxies and `/etc/hosts` entries and closes the tunnels for the domains in your `magicserve.json`. Your servers keep running.
105
+ - **`magicserve status`**: Shows whether a server is currently listening on each domain's port, plus the status and public URL of any tunnels.
106
+ - **`magicserve stopall`**: Emergency command. Destroys ALL Nginx proxy configs, tunnels, SSL certificates and custom `localhost` entries system-wide, restoring your machine's clean state. (It no longer kills your app servers — those are yours to manage.)
109
107
 
110
108
  ---
111
109
 
110
+ ### Features in v2.0.0 🔌 (Breaking)
111
+
112
+ - **You run your own servers.** Magicserve no longer launches `node`/`php` processes — it only sets up the Nginx HTTPS proxy, SSL certificate, `/etc/hosts` entry and optional tunnel pointing at the port you bring up yourself (works with **any** stack: Node, PHP, Python, Go, …).
113
+ - **Simpler config.** `magicserve.json` now takes only `domain` + `port` (+ optional `tunnel`). The `path` and `type` properties have been removed.
114
+ - **`stop` is non-destructive to your apps.** It tears down the proxy and tunnels only; your servers keep running.
115
+ - **`status` probes the port.** It now reports whether something is listening on each port (via `lsof`) instead of tracking a server PID.
116
+ - **`stopall` no longer kills app servers** (those are yours to manage); it still purges all proxies, tunnels, certificates and custom `hosts` entries.
117
+
118
+ > **Migrating from v1.x:** remove `path` and `type` from each entry in your `magicserve.json`, and start your servers yourself before/after running `magicserve start`.
119
+
112
120
  ### Features in v1.2.0 🚇
113
121
 
114
122
  - **Integrated Localtunnel**: Permanently and automatically expose any of your API ports to the internet via the new `tunnel` property in config JSON to seamlessly receive third-party **Webhooks** (Mercado Libre, Stripe, etc).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "magicserve",
3
- "version": "1.2.6",
4
- "description": "Script to run local environments via magicserve.json",
3
+ "version": "2.0.2",
4
+ "description": "CLI to wire local HTTPS domains, SSL and tunnels to ports you run yourself",
5
5
  "files": [
6
6
  "run.sh",
7
7
  "package.json"
package/run.sh CHANGED
@@ -45,45 +45,13 @@ usage() {
45
45
  echo " magicserve [start|stop|stopall|status|init]"
46
46
  echo ""
47
47
  echo " init - Crea un archivo magicserve.json de plantilla en la carpeta actual"
48
- echo " start - Inicia todos los servicios del magicserve.json"
49
- echo " stop - Detiene los servicios del magicserve.json"
50
- echo " stopall - Busca y detiene TODOS los dominios (sin depender de magicserve.json) y borra todo rastro"
51
- echo " status - Muestra el estado de los servicios"
48
+ echo " start - Configura proxy Nginx (HTTPS) y túneles para los dominios del magicserve.json"
49
+ echo " stop - Detiene los proxys y túneles del magicserve.json (no toca tus servidores)"
50
+ echo " stopall - Borra TODOS los proxys, túneles, certificados y entradas de hosts (sin depender de magicserve.json)"
51
+ echo " status - Muestra si hay un servidor escuchando en cada puerto y el estado de los túneles"
52
52
  exit 1
53
53
  }
54
54
 
55
- start_server() {
56
- local PATH_DIR=$1
57
- local DOMAIN=$2
58
- local TYPE=$3
59
- local PORT=$4
60
-
61
- local PID_FILE="$PIDS_DIR/${DOMAIN}.pid"
62
-
63
- echo "🚀 Iniciando $DOMAIN ($TYPE) en puerto $PORT..."
64
-
65
- # Navegar al directorio del proyecto relativo al script
66
- cd "$SCRIPT_DIR/$PATH_DIR" || {
67
- echo "❌ Error: Directorio $PATH_DIR no encontrado para $DOMAIN"
68
- return
69
- }
70
-
71
- if [ "$TYPE" == "node" ]; then
72
- nohup npm run dev -- --port $PORT > "$LOGS_DIR/${DOMAIN}.log" 2>&1 &
73
- local PID=$!
74
- echo $PID > "$PID_FILE"
75
- echo "✅ Node corriendo (PID: $PID)"
76
- elif [ "$TYPE" == "php" ]; then
77
- # El docroot por defecto para php es el directorio actual
78
- nohup php -d upload_max_filesize=100M -d post_max_size=100M -S "localhost:$PORT" -t . > "$LOGS_DIR/${DOMAIN}.log" 2>&1 &
79
- local PID=$!
80
- echo $PID > "$PID_FILE"
81
- echo "✅ PHP corriendo (PID: $PID)"
82
- else
83
- echo "❌ Tipo $TYPE no soportado (usa 'node' o 'php')"
84
- fi
85
- }
86
-
87
55
  start_proxy() {
88
56
  local DOMAIN=$1
89
57
  local PORT=$2
@@ -164,6 +132,7 @@ start_tunnel() {
164
132
 
165
133
  echo "🚇 Iniciando túnel para $DOMAIN en puerto $PORT..."
166
134
  local TUNNEL_PID_FILE="$PIDS_DIR/${DOMAIN}_tunnel.pid"
135
+ local TUNNEL_URL_FILE="$PIDS_DIR/${DOMAIN}_tunnel.url"
167
136
 
168
137
  # Si pasaron false o null, no hacer nada
169
138
  if [ "$TUNNEL_SUBDOMAIN" == "false" ] || [ "$TUNNEL_SUBDOMAIN" == "null" ] || [ -z "$TUNNEL_SUBDOMAIN" ]; then
@@ -174,27 +143,41 @@ start_tunnel() {
174
143
 
175
144
  if [ "$TUNNEL_SUBDOMAIN" == "true" ]; then
176
145
  nohup npx localtunnel --port $PORT > "$TUNNEL_LOG" 2>&1 &
146
+ local PID=$!
147
+ echo $PID > "$TUNNEL_PID_FILE"
148
+ echo "✅ Túnel corriendo (PID: $PID)"
149
+ # Esperar a que localtunnel imprima la URL dinámica
150
+ echo "⏳ Esperando URL del túnel..."
151
+ sleep 4
152
+ local URL=$(grep -o 'https://[^ ]*' "$TUNNEL_LOG" 2>/dev/null | head -1)
153
+ if [ -n "$URL" ]; then
154
+ echo "$URL" > "$TUNNEL_URL_FILE"
155
+ echo "🌐 URL pública del túnel: $URL"
156
+ else
157
+ echo "⚠️ No se pudo obtener la URL del túnel aún. Revisa: $TUNNEL_LOG"
158
+ fi
177
159
  else
178
160
  nohup npx localtunnel --port $PORT --subdomain "$TUNNEL_SUBDOMAIN" > "$TUNNEL_LOG" 2>&1 &
161
+ local PID=$!
162
+ echo $PID > "$TUNNEL_PID_FILE"
163
+ local URL="https://${TUNNEL_SUBDOMAIN}.loca.lt"
164
+ echo "$URL" > "$TUNNEL_URL_FILE"
165
+ echo "✅ Túnel corriendo (PID: $PID)"
166
+ echo "🌐 URL pública del túnel: $URL"
179
167
  fi
180
-
181
- local PID=$!
182
- echo $PID > "$TUNNEL_PID_FILE"
183
- echo "✅ Túnel corriendo (PID: $PID)"
184
168
  }
185
169
 
186
170
  start_all() {
187
- echo "🌟 Iniciando todos los servicios desde magicserve.json..."
171
+ echo "🌟 Configurando proxys y túneles desde magicserve.json..."
172
+ echo "💡 Recuerda: tú debes levantar tus servidores (node/php/python/etc) en los puertos indicados."
173
+ echo ""
188
174
 
189
175
  local LENGTH=$(jq '. | length' "$CONFIG_FILE")
190
176
  for (( i=0; i<$LENGTH; i++ )); do
191
- local PATH_DIR=$(jq -r ".[$i].path" "$CONFIG_FILE")
192
177
  local DOMAIN=$(jq -r ".[$i].domain" "$CONFIG_FILE")
193
- local TYPE=$(jq -r ".[$i].type" "$CONFIG_FILE")
194
178
  local PORT=$(jq -r ".[$i].port" "$CONFIG_FILE")
195
179
  local TUNNEL=$(jq -r ".[$i].tunnel // empty" "$CONFIG_FILE")
196
180
 
197
- start_server "$PATH_DIR" "$DOMAIN" "$TYPE" "$PORT"
198
181
  start_proxy "$DOMAIN" "$PORT"
199
182
 
200
183
  if [ -n "$TUNNEL" ]; then
@@ -213,7 +196,7 @@ start_all() {
213
196
  }
214
197
 
215
198
  stop_all() {
216
- echo "🛑 Deteniendo todos los servicios..."
199
+ echo "🛑 Deteniendo proxys y túneles..."
217
200
 
218
201
  local HOSTS_FILE="/etc/hosts"
219
202
  local NGINX_SERVER_DIR="/opt/homebrew/etc/nginx/servers"
@@ -221,20 +204,9 @@ stop_all() {
221
204
  local LENGTH=$(jq '. | length' "$CONFIG_FILE")
222
205
  for (( i=0; i<$LENGTH; i++ )); do
223
206
  local DOMAIN=$(jq -r ".[$i].domain" "$CONFIG_FILE")
224
- local PID_FILE="$PIDS_DIR/${DOMAIN}.pid"
225
-
226
- if [ -f "$PID_FILE" ]; then
227
- local PID=$(cat "$PID_FILE")
228
- if ps -p $PID > /dev/null; then
229
- kill $PID
230
- echo "🛑 Servidor para $DOMAIN detenido (PID: $PID)."
231
- else
232
- echo "⚠️ Proceso para $DOMAIN no encontrado (el archivo PID será limpiado)."
233
- fi
234
- rm "$PID_FILE"
235
- fi
236
207
 
237
208
  local TUNNEL_PID_FILE="$PIDS_DIR/${DOMAIN}_tunnel.pid"
209
+ local TUNNEL_URL_FILE="$PIDS_DIR/${DOMAIN}_tunnel.url"
238
210
  if [ -f "$TUNNEL_PID_FILE" ]; then
239
211
  local TPID=$(cat "$TUNNEL_PID_FILE")
240
212
  if ps -p $TPID > /dev/null; then
@@ -244,6 +216,7 @@ stop_all() {
244
216
  echo "⚠️ Proceso de túnel para $DOMAIN no encontrado."
245
217
  fi
246
218
  rm "$TUNNEL_PID_FILE"
219
+ rm -f "$TUNNEL_URL_FILE"
247
220
  fi
248
221
 
249
222
  # Limpiar de /etc/hosts
@@ -261,7 +234,7 @@ stop_all() {
261
234
  sudo nginx -s reload > /dev/null 2>&1
262
235
  fi
263
236
 
264
- echo "✅ Todo detenido."
237
+ echo "✅ Proxys y túneles detenidos. (Tus servidores siguen corriendo, deténlos tú mismo)."
265
238
  }
266
239
 
267
240
  status() {
@@ -269,24 +242,28 @@ status() {
269
242
  local LENGTH=$(jq '. | length' "$CONFIG_FILE")
270
243
  for (( i=0; i<$LENGTH; i++ )); do
271
244
  local DOMAIN=$(jq -r ".[$i].domain" "$CONFIG_FILE")
272
- local PID_FILE="$PIDS_DIR/${DOMAIN}.pid"
245
+ local PORT=$(jq -r ".[$i].port" "$CONFIG_FILE")
273
246
 
274
- if [ -f "$PID_FILE" ]; then
275
- local PID=$(cat "$PID_FILE")
276
- if ps -p $PID > /dev/null; then
277
- echo "🟢 $DOMAIN: Corriendo (PID: $PID)"
278
- else
279
- echo "🔴 $DOMAIN: Archivo PID existe pero el proceso no está corriendo"
280
- fi
247
+ # No gestionamos el proceso del servidor: comprobamos si algo escucha en el puerto
248
+ local LISTENER=$(lsof -nP -iTCP:$PORT -sTCP:LISTEN -t 2>/dev/null | head -1)
249
+ if [ -n "$LISTENER" ]; then
250
+ echo "🟢 $DOMAIN localhost:$PORT (servidor escuchando, PID: $LISTENER)"
281
251
  else
282
- echo "⚪️ $DOMAIN: Detenido"
252
+ echo "⚪️ $DOMAIN → localhost:$PORT (nada escuchando — levanta tu servidor)"
283
253
  fi
284
254
 
285
255
  local TUNNEL_PID_FILE="$PIDS_DIR/${DOMAIN}_tunnel.pid"
256
+ local TUNNEL_URL_FILE="$PIDS_DIR/${DOMAIN}_tunnel.url"
286
257
  if [ -f "$TUNNEL_PID_FILE" ]; then
287
258
  local TPID=$(cat "$TUNNEL_PID_FILE")
288
259
  if ps -p $TPID > /dev/null; then
289
- echo " ↳ 🚇 Túnel expuesto (PID: $TPID)"
260
+ local TURL=""
261
+ [ -f "$TUNNEL_URL_FILE" ] && TURL=$(cat "$TUNNEL_URL_FILE")
262
+ if [ -n "$TURL" ]; then
263
+ echo " ↳ 🚇 Túnel activo (PID: $TPID) → 🌐 $TURL"
264
+ else
265
+ echo " ↳ 🚇 Túnel activo (PID: $TPID)"
266
+ fi
290
267
  else
291
268
  echo " ↳ 🔴 Túnel: Archivo PID existe pero no está corriendo"
292
269
  fi
@@ -325,35 +302,11 @@ stop_all_global() {
325
302
  echo " ✅ No se encontraron archivos .pid"
326
303
  fi
327
304
 
328
- # ─── 2. Matar TODOS los servidores PHP built-in de la computadora ───
329
- echo ""
330
- echo "🔍 Buscando servidores PHP built-in (php -S)..."
331
- local PHP_PIDS=$(pgrep -f "php -S" 2>/dev/null)
332
- if [ -n "$PHP_PIDS" ]; then
333
- echo "$PHP_PIDS" | while read PID; do
334
- local CMD=$(ps -p $PID -o args= 2>/dev/null)
335
- kill $PID 2>/dev/null
336
- echo " 🛑 PHP detenido (PID: $PID) → $CMD"
337
- done
338
- else
339
- echo " ✅ No se encontraron servidores PHP"
340
- fi
341
-
342
- # ─── 3. Matar TODOS los servidores Node de desarrollo ───
343
- echo ""
344
- echo "🔍 Buscando servidores Node de desarrollo (vite, next, nuxt, webpack)..."
345
- local NODE_PIDS=$(pgrep -f "(vite|next dev|nuxt|webpack-dev-server|node.*dev)" 2>/dev/null)
346
- if [ -n "$NODE_PIDS" ]; then
347
- echo "$NODE_PIDS" | while read PID; do
348
- local CMD=$(ps -p $PID -o args= 2>/dev/null | head -c 120)
349
- kill $PID 2>/dev/null
350
- echo " 🛑 Node detenido (PID: $PID) → $CMD"
351
- done
352
- else
353
- echo " ✅ No se encontraron servidores Node de desarrollo"
354
- fi
305
+ # NOTA: Magicserve ya no lanza servidores (node/php/python), así que tampoco
306
+ # los mata aquí. Tus servidores los gestionas tú. Solo limpiamos lo que
307
+ # Magicserve crea: túneles, configs de nginx, /etc/hosts, certificados y logs.
355
308
 
356
- # ─── 3.5. Matar procesos de localtunnel ───
309
+ # ─── 2. Matar procesos de localtunnel ───
357
310
  echo ""
358
311
  echo "🔍 Buscando procesos de localtunnel..."
359
312
  local LT_PIDS=$(pgrep -f "localtunnel" 2>/dev/null)
@@ -441,15 +394,11 @@ init_config() {
441
394
  cat <<EOF > "$CONFIG_FILE"
442
395
  [
443
396
  {
444
- "path": "../tu-proyecto-frontal",
445
397
  "domain": "tu-proyecto.test",
446
- "type": "node",
447
398
  "port": 3000
448
399
  },
449
400
  {
450
- "path": "../tu-api-backend",
451
401
  "domain": "api.tu-proyecto.test",
452
- "type": "php",
453
402
  "port": 3001,
454
403
  "tunnel": "mi-super-api-dev"
455
404
  }