Skip to content

Commit 9ffe545

Browse files
authored
Merge pull request #37 from openSVM/develop
Develop
2 parents db5e35e + dc7460f commit 9ffe545

File tree

4 files changed

+82
-19
lines changed

4 files changed

+82
-19
lines changed

manage-local-rpc.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Script to manage local Solana RPC node
4+
5+
case "$1" in
6+
start)
7+
if pgrep -f "solana-test-validator" > /dev/null; then
8+
echo "❌ Solana test validator is already running"
9+
exit 1
10+
fi
11+
echo "🚀 Starting Solana test validator..."
12+
nohup solana-test-validator --reset > /tmp/solana-test-validator.log 2>&1 &
13+
echo "✅ Started with PID: $!"
14+
echo "📍 RPC URL: http://127.0.0.1:8899"
15+
echo "🔌 WebSocket URL: ws://127.0.0.1:8900"
16+
echo "📄 Log file: /tmp/solana-test-validator.log"
17+
;;
18+
stop)
19+
echo "🛑 Stopping Solana test validator..."
20+
pkill -f solana-test-validator
21+
echo "✅ Stopped"
22+
;;
23+
status)
24+
if pgrep -f "solana-test-validator" > /dev/null; then
25+
echo "✅ Solana test validator is running"
26+
echo "📍 RPC URL: http://127.0.0.1:8899"
27+
echo "🔌 WebSocket URL: ws://127.0.0.1:8900"
28+
# Check health
29+
if curl -s -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}' http://127.0.0.1:8899 | grep -q '"result":"ok"'; then
30+
echo "💚 Health: OK"
31+
else
32+
echo "❌ Health: Not responding"
33+
fi
34+
else
35+
echo "❌ Solana test validator is not running"
36+
fi
37+
;;
38+
logs)
39+
if [ -f /tmp/solana-test-validator.log ]; then
40+
tail -f /tmp/solana-test-validator.log
41+
else
42+
echo "❌ No log file found"
43+
fi
44+
;;
45+
*)
46+
echo "Usage: $0 {start|stop|status|logs}"
47+
exit 1
48+
;;
49+
esac

src/clparse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,8 @@ pub fn parse_command_line() -> clap::ArgMatches {
913913
.action(ArgAction::SetTrue)
914914
.help("Enable transaction history (increases storage requirements)")
915915
)
916-
)
916+
)
917+
)
917918
.subcommand(
918919
Command::new("doctor")
919920
.about("Comprehensive system health check and repair")

src/utils/log_monitor.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,30 @@ async fn setup_ngrok_tunnels(ports: &[u16]) -> Result<HashMap<u16, String>> {
288288
for &port in ports {
289289
println!("🔗 Creating ngrok tunnel for port {}", port);
290290

291-
// Start ngrok in background
292-
let mut child = Command::new("ngrok")
293-
.arg("tcp")
294-
.arg(port.to_string())
295-
.arg("--log")
296-
.arg("stdout")
297-
.spawn()
298-
.context("Failed to start ngrok")?;
291+
// Use HTTP tunnel with custom domain for RPC ports (8899), TCP for others
292+
let mut child = if port == 8899 {
293+
// HTTP tunnel for RPC endpoint with custom domain
294+
Command::new("ngrok")
295+
.arg("http")
296+
.arg(format!("localhost:{}", port))
297+
.arg("--domain")
298+
.arg(format!("osvm.dev"))
299+
.arg("--log")
300+
.arg("stdout")
301+
.spawn()
302+
.context("Failed to start ngrok")?
303+
} else {
304+
// TCP tunnel with custom remote address for gossip/other ports
305+
Command::new("ngrok")
306+
.arg("tcp")
307+
.arg(port.to_string())
308+
.arg("--remote-addr")
309+
.arg(format!("{}.osvm.dev:{}", port, port))
310+
.arg("--log")
311+
.arg("stdout")
312+
.spawn()
313+
.context("Failed to start ngrok")?
314+
};
299315

300316
// Give ngrok time to start
301317
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;

src/utils/ssh_deploy/deployments/solana.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,9 @@ fn install_solana_cli(
194194
Some("firedancer") => {
195195
// Install Firedancer client
196196
let temp_dir = "/tmp/firedancer";
197-
let cleanup = || {
198-
let _ = client.execute_command(&format!("rm -rf {}", temp_dir));
199-
};
200197

201198
// Wrap installation steps in error handling
202-
if let Err(e) = (|| -> Result<(), DeploymentError> {
199+
let result = (|| -> Result<(), DeploymentError> {
203200
// First install dependencies
204201
client.execute_command("sudo apt-get update && sudo apt-get install -y build-essential cmake pkg-config libssl-dev")?;
205202

@@ -216,13 +213,13 @@ fn install_solana_cli(
216213
client.execute_command("sudo ln -sf /opt/firedancer/bin/fd_keygen /usr/local/bin/solana-keygen")?;
217214

218215
Ok(())
219-
})() {
220-
cleanup();
221-
return Err(e);
222-
}
216+
})();
223217

224-
// Clean up
225-
cleanup();
218+
// Clean up regardless of success or failure
219+
let _ = client.execute_command(&format!("rm -rf {}", temp_dir));
220+
221+
// Return result after cleanup
222+
result?;
226223
}
227224
Some("sig") => {
228225
// Install Sig (Solana Zig Validator)

0 commit comments

Comments
 (0)