@powerhousedao/ph-cli 2.5.0-dev.12 → 2.5.0-dev.13

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "2.5.0-dev.12",
3
+ "version": "2.5.0-dev.13",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -6,6 +6,12 @@
6
6
  PROJECT_NAME=${1:-"global"}
7
7
  ACTION=${2:-"status"}
8
8
 
9
+ # Get Switchboard port from .env or use default
10
+ if [ -f ".env" ]; then
11
+ SWITCHBOARD_PORT=$(grep "SWITCHBOARD_PORT=" .env | cut -d'=' -f2)
12
+ fi
13
+ SWITCHBOARD_PORT=${SWITCHBOARD_PORT:-4001}
14
+
9
15
  # =============================================================================
10
16
  # OS Detection and Windows Handling
11
17
  # =============================================================================
@@ -95,7 +101,7 @@ else
95
101
  # Start Switchboard via PM2
96
102
  if ! pm2 list | grep -q "switchboard_${PROJECT_NAME}"; then
97
103
  cd $PROJECT_NAME
98
- pm2 start "pnpm switchboard" --name "switchboard_${PROJECT_NAME}"
104
+ pm2 start "pnpm switchboard --port $SWITCHBOARD_PORT" --name "switchboard_${PROJECT_NAME}"
99
105
  pm2 save
100
106
  else
101
107
  pm2 start "switchboard_${PROJECT_NAME}"
@@ -6,6 +6,15 @@
6
6
  TARGET_TAG=${1:-"latest"}
7
7
  PROJECT_NAME=${2:-"global"}
8
8
 
9
+ # Function to find an available port
10
+ find_available_port() {
11
+ local port=4001
12
+ while netstat -tuln | grep -q ":$port "; do
13
+ port=$((port + 1))
14
+ done
15
+ echo $port
16
+ }
17
+
9
18
  # =============================================================================
10
19
  # OS Detection and Windows Handling
11
20
  # =============================================================================
@@ -114,6 +123,13 @@ EOF
114
123
  echo " SSL Configuration"
115
124
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
116
125
 
126
+ # Find an available port for Switchboard
127
+ SWITCHBOARD_PORT=$(find_available_port)
128
+ echo "Using port $SWITCHBOARD_PORT for Switchboard"
129
+
130
+ # Save Switchboard port to configuration
131
+ echo "SWITCHBOARD_PORT=$SWITCHBOARD_PORT" | sudo tee -a .env
132
+
117
133
  # Add compression settings to nginx.conf if not exists
118
134
  if ! grep -q "brotli_comp_level" /etc/nginx/nginx.conf || ! grep -q "gzip_comp_level" /etc/nginx/nginx.conf; then
119
135
  echo "Adding compression settings to nginx.conf..."
@@ -276,7 +292,7 @@ server {
276
292
  add_header X-XSS-Protection "1; mode=block";
277
293
 
278
294
  location / {
279
- proxy_pass http://localhost:4001;
295
+ proxy_pass http://localhost:$SWITCHBOARD_PORT;
280
296
  proxy_http_version 1.1;
281
297
  proxy_set_header Upgrade \$http_upgrade;
282
298
  proxy_set_header Connection 'upgrade';
@@ -343,7 +359,7 @@ server {
343
359
  }
344
360
 
345
361
  location /switchboard {
346
- proxy_pass http://localhost:4001;
362
+ proxy_pass http://localhost:$SWITCHBOARD_PORT;
347
363
  proxy_http_version 1.1;
348
364
  proxy_set_header Upgrade \$http_upgrade;
349
365
  proxy_set_header Connection 'upgrade';
@@ -1,2 +1,2 @@
1
- export declare const version = "2.5.0-dev.12";
1
+ export declare const version = "2.5.0-dev.13";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated. DO NOT EDIT.
2
- export const version = "2.5.0-dev.12";
2
+ export const version = "2.5.0-dev.13";
3
3
  //# sourceMappingURL=version.js.map