@@ -63,9 +63,9 @@ impl ProtocolAdapter for DimseAdapter {
6363 ) -> anyhow:: Result < JoinHandle < ( ) > > {
6464 let network_name = self . network_name . clone ( ) ;
6565
66- tracing:: info !( "Starting DIMSE adapter for network '{}'" , network_name) ;
66+ tracing:: debug !( "Starting DIMSE adapter for network '{}'" , network_name) ;
6767
68- // Get all DIMSE endpoints for this network from pipelines
68+ // Collect all DIMSE-related endpoints and backends for this network
6969 let mut scp_configs: Vec < ( String , String , HashMap < String , serde_json:: Value > ) > = Vec :: new ( ) ;
7070
7171 for ( pipeline_name, pipeline_cfg) in & config. pipelines {
@@ -74,11 +74,11 @@ impl ProtocolAdapter for DimseAdapter {
7474 continue ;
7575 }
7676
77- // Check all endpoints in this pipeline
77+ // Check all endpoints in this pipeline for DIMSE services
7878 for endpoint_name in & pipeline_cfg. endpoints {
7979 if let Some ( endpoint) = config. endpoints . get ( endpoint_name) {
80- // Check if this endpoint is DIMSE by service name
81- if endpoint. service == "dimse" {
80+ // Support: "dimse" (legacy), "dicom_scp" (new)
81+ if matches ! ( endpoint. service. as_str ( ) , "dimse" | "dicom_scp" ) {
8282 scp_configs. push ( (
8383 pipeline_name. clone ( ) ,
8484 endpoint_name. clone ( ) ,
@@ -87,13 +87,41 @@ impl ProtocolAdapter for DimseAdapter {
8787 }
8888 }
8989 }
90+
91+ // Also check for persistent SCP backends (legacy support)
92+ for backend_name in & pipeline_cfg. backends {
93+ if let Some ( backend) = config. backends . get ( backend_name) {
94+ // Legacy persistent DICOM SCP backends
95+ if backend. service == "dicom" {
96+ if let Some ( options) = & backend. options {
97+ let needs_persistent = options
98+ . get ( "persistent_store_scp" )
99+ . and_then ( |v| v. as_bool ( ) )
100+ . unwrap_or ( false )
101+ || ( options. contains_key ( "host" ) && options. contains_key ( "port" ) ) ;
102+
103+ if needs_persistent && options. contains_key ( "incoming_store_port" ) {
104+ scp_configs. push ( (
105+ pipeline_name. clone ( ) ,
106+ format ! ( "persistent_{}" , backend_name) ,
107+ options. clone ( ) ,
108+ ) ) ;
109+ }
110+ }
111+ }
112+ }
113+ }
90114 }
91115
92116 if scp_configs. is_empty ( ) {
93- tracing:: warn !(
94- "No DIMSE endpoints found for network '{}', adapter will be idle " ,
117+ tracing:: debug !(
118+ "No DIMSE endpoints or persistent SCPs found for network '{}'" ,
95119 network_name
96120 ) ;
121+ // Return idle adapter
122+ return Ok ( tokio:: spawn ( async move {
123+ shutdown. cancelled ( ) . await ;
124+ } ) ) ;
97125 }
98126
99127 // Spawn task to manage SCPs
@@ -159,8 +187,10 @@ impl DimseAdapter {
159187 . and_then ( |s| s. parse :: < IpAddr > ( ) . ok ( ) )
160188 . unwrap_or_else ( || IpAddr :: from ( std:: net:: Ipv4Addr :: new ( 0 , 0 , 0 , 0 ) ) ) ;
161189
190+ // For persistent backends, use incoming_store_port; for endpoints, use port
162191 let port = options
163- . get ( "port" )
192+ . get ( "incoming_store_port" )
193+ . or_else ( || options. get ( "port" ) )
164194 . and_then ( |v| v. as_u64 ( ) )
165195 . map ( |p| p as u16 )
166196 . unwrap_or ( DEFAULT_DIMSE_PORT ) ;
0 commit comments