1- use std:: str:: FromStr ;
1+ use std:: {
2+ net:: { IpAddr , SocketAddr } ,
3+ str:: FromStr ,
4+ } ;
25
36use clap:: { Args , Parser , Subcommand , arg} ;
47use pyo3:: prelude:: * ;
58use tracing_subscriber:: { self , filter:: Directive , layer:: SubscriberExt , util:: SubscriberInitExt } ;
69
710#[ derive( Debug , Args ) ]
811struct DashboardArgs {
12+ /// The address to launch the dashboard on
13+ #[ arg( short, long, default_value = "0.0.0.0" ) ]
14+ addr : IpAddr ,
915 #[ arg( short, long, default_value_t = 80 ) ]
1016 /// The port to launch the dashboard on
1117 port : u16 ,
@@ -35,6 +41,15 @@ fn run_dashboard(py: Python, args: DashboardArgs) {
3541 let filter = Directive :: from_str ( if args. verbose { "INFO" } else { "ERROR" } )
3642 . expect ( "Failed to parse tracing filter" ) ;
3743
44+ if args. addr . is_unspecified ( ) {
45+ println ! ( "{}" , console:: style( format!(
46+ "⚠️ Listening on all network interfaces ({})! This is not recommended in production." ,
47+ args. addr
48+ ) ) . yellow( ) . bold( ) ) ;
49+ }
50+
51+ let socket_addr = SocketAddr :: from ( ( args. addr , args. port ) ) ;
52+
3853 // Set the subscriber for the detached run
3954 tracing_subscriber:: registry ( )
4055 . with (
@@ -56,26 +71,25 @@ fn run_dashboard(py: Python, args: DashboardArgs) {
5671 "{} To get started, run your Daft script with env `{}`" ,
5772 console:: style( "█" ) . magenta( ) ,
5873 console:: style( format!(
59- "DAFT_DASHBOARD_URL=\" http://{}:{}\" python ..." ,
60- daft_dashboard:: DEFAULT_SERVER_ADDR ,
61- args. port
74+ "DAFT_DASHBOARD_URL=\" http://{}\" python ..." ,
75+ socket_addr
6276 ) )
6377 . bold( ) ,
6478 ) ;
6579 println ! (
6680 "✨ View the dashboard at {}. Press Ctrl+C to shutdown" ,
67- console:: style( format!(
68- "http://{}:{}" ,
69- daft_dashboard:: DEFAULT_SERVER_ADDR ,
70- args. port
71- ) )
72- . bold( )
73- . magenta( )
74- . underlined( ) ,
81+ console:: style( format!( "http://{}" , socket_addr) )
82+ . bold( )
83+ . magenta( )
84+ . underlined( ) ,
7585 ) ;
76- daft_dashboard:: launch_server ( args. port , async move { shutdown_rx. await . unwrap ( ) } )
77- . await
78- . expect ( "Failed to launch dashboard server" ) ;
86+ daft_dashboard:: launch_server (
87+ args. addr ,
88+ args. port ,
89+ async move { shutdown_rx. await . unwrap ( ) } ,
90+ )
91+ . await
92+ . expect ( "Failed to launch dashboard server" ) ;
7993 } ) ;
8094
8195 loop {
0 commit comments