Elysiadev11 commited on
Commit
1012339
Β·
verified Β·
1 Parent(s): dc78112

Update start-openclaw.sh

Browse files
Files changed (1) hide show
  1. start-openclaw.sh +12 -7
start-openclaw.sh CHANGED
@@ -23,7 +23,6 @@ echo ">>> Restore done."
23
  echo "nameserver 1.1.1.1" >> /etc/resolv.conf
24
  echo "nameserver 8.8.8.8" >> /etc/resolv.conf
25
  echo "nameserver 8.8.4.4" >> /etc/resolv.conf
26
- # Memaksa routing Telegram agar tidak diblokir oleh DNS internal K8s HF
27
  echo "149.154.166.110 api.telegram.org" >> /etc/hosts
28
  echo ">>> DNS and Hosts fixed for Telegram."
29
 
@@ -131,11 +130,14 @@ cat > /root/.openclaw/openclaw.json <<EOF
131
  EOF
132
  echo ">>> openclaw.json generated with Primary, Fallback, and split ports."
133
 
134
- # ── 7. Node.js reverse proxy di port 7860 ─────────────────────
135
  node -e "
136
  const http = require('http');
137
  const net = require('net');
138
 
 
 
 
139
  function proxyHttp(req, res, targetPort) {
140
  const opts = {
141
  hostname: '127.0.0.1', port: targetPort,
@@ -146,7 +148,12 @@ function proxyHttp(req, res, targetPort) {
146
  res.writeHead(r.statusCode, r.headers);
147
  r.pipe(res, { end: true });
148
  });
149
- pr.on('error', (e) => { res.writeHead(502); res.end('Bad gateway: ' + e.message); });
 
 
 
 
 
150
  req.pipe(pr, { end: true });
151
  }
152
 
@@ -161,7 +168,7 @@ function proxyWs(req, socket, head, targetPort) {
161
  socket.pipe(conn);
162
  conn.pipe(socket);
163
  });
164
- conn.on('error', (e) => { console.error('WS proxy error:', e.message); socket.destroy(); });
165
  socket.on('error', () => conn.destroy());
166
  }
167
 
@@ -176,9 +183,7 @@ server.on('upgrade', (req, socket, head) => {
176
  });
177
 
178
  server.listen(7860, '0.0.0.0', () => {
179
- console.log('Proxy (HTTP+WebSocket) on port 7860');
180
- console.log(' /telegram/webhook β†’ :8787');
181
- console.log(' /* (incl. WSS) β†’ :7862');
182
  });
183
  " &
184
  echo ">>> Node.js WebSocket proxy started on port 7860."
 
23
  echo "nameserver 1.1.1.1" >> /etc/resolv.conf
24
  echo "nameserver 8.8.8.8" >> /etc/resolv.conf
25
  echo "nameserver 8.8.4.4" >> /etc/resolv.conf
 
26
  echo "149.154.166.110 api.telegram.org" >> /etc/hosts
27
  echo ">>> DNS and Hosts fixed for Telegram."
28
 
 
130
  EOF
131
  echo ">>> openclaw.json generated with Primary, Fallback, and split ports."
132
 
133
+ # ── 7. Node.js reverse proxy (ANTI-TIMEOUT TRICK) ─────────────
134
  node -e "
135
  const http = require('http');
136
  const net = require('net');
137
 
138
+ // Mencegah proxy mati kalau ada error mendadak
139
+ process.on('uncaughtException', err => console.error('Proxy Exception:', err.message));
140
+
141
  function proxyHttp(req, res, targetPort) {
142
  const opts = {
143
  hostname: '127.0.0.1', port: targetPort,
 
148
  res.writeHead(r.statusCode, r.headers);
149
  r.pipe(res, { end: true });
150
  });
151
+
152
+ // JIKA OPENCLAW BELUM NYALA, BALAS 200 OK AGAR HF SPACE MENGANGGAP SEHAT!
153
+ pr.on('error', (e) => {
154
+ res.writeHead(200, { 'Content-Type': 'text/html' });
155
+ res.end('<html style=\"background:#1e1e2e; color:#cdd6f4; font-family:sans-serif; text-align:center; padding-top:20%;\"><body><h2>πŸš€ OpenClaw is warming up...</h2><p>Hugging Face is downloading dependencies. Please refresh in a few seconds.</p></body></html>');
156
+ });
157
  req.pipe(pr, { end: true });
158
  }
159
 
 
168
  socket.pipe(conn);
169
  conn.pipe(socket);
170
  });
171
+ conn.on('error', (e) => { socket.destroy(); });
172
  socket.on('error', () => conn.destroy());
173
  }
174
 
 
183
  });
184
 
185
  server.listen(7860, '0.0.0.0', () => {
186
+ console.log('Proxy (HTTP+WebSocket) on port 7860 (Anti-Timeout Active)');
 
 
187
  });
188
  " &
189
  echo ">>> Node.js WebSocket proxy started on port 7860."