File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 77using System . Data ;
88using System . Data . Common ;
99using System . Linq ;
10+ using System . Net . NetworkInformation ;
1011using System . Text . Json . Nodes ;
1112using System . Threading ;
1213using System . Threading . Tasks ;
@@ -33,7 +34,11 @@ public static long DateTimeToLongTimeStamp()
3334 private static void Main ( string [ ] args )
3435 {
3536 var IS_RUNNING_IN_CONTAINER = bool . TryParse ( Environment . GetEnvironmentVariable ( "DOTNET_RUNNING_IN_CONTAINER" ) , out bool _DOTNET_RUNNING_IN_CONTAINER ) && _DOTNET_RUNNING_IN_CONTAINER ;
36- var _dbhost = IS_RUNNING_IN_CONTAINER ? "taos" : "localhost" ;
37+ var _dbhost = IS_RUNNING_IN_CONTAINER ? "taos" : System . Net . Dns . GetHostName ( ) ;
38+ Console . WriteLine ( $ "主机名:{ _dbhost } 当前程序运行在{ ( IS_RUNNING_IN_CONTAINER ? "容器内" : "主机中" ) } ") ;
39+ var p = new Ping ( ) ;
40+ var pr = p . Send ( _dbhost , ( int ) TimeSpan . FromSeconds ( 5 ) . TotalMilliseconds ) ;
41+ Console . WriteLine ( $ "{ pr . Status } { pr . RoundtripTime } ") ;
3742 System . Text . Encoding . RegisterProvider ( System . Text . CodePagesEncodingProvider . Instance ) ;
3843 DbProviderFactories . RegisterFactory ( "TDengine" , TaosFactory . Instance ) ;
3944 string database = "db_" + DateTime . Now . ToString ( "yyyyMMddHHmmss" ) ;
You can’t perform that action at this time.
0 commit comments