112112
113113
114114def register_sighup (
115- homeserver_instance_id : str ,
115+ hs : "HomeServer" ,
116116 func : Callable [P , None ],
117117 * args : P .args ,
118118 ** kwargs : P .kwargs ,
@@ -127,19 +127,25 @@ def register_sighup(
127127 *args, **kwargs: args and kwargs to be passed to the target function.
128128 """
129129
130- _instance_id_to_sighup_callbacks_map .setdefault (homeserver_instance_id , []).append (
131- (func , args , kwargs )
130+ # Wrap the function so we can run it within a logcontext
131+ def _callback_wrapper (* args : P .args , ** kwargs : P .kwargs ) -> None :
132+ with LoggingContext (name = "sighup" , server_name = hs .hostname ):
133+ func (* args , ** kwargs )
134+
135+ _instance_id_to_sighup_callbacks_map .setdefault (hs .get_instance_id (), []).append (
136+ (_callback_wrapper , args , kwargs )
132137 )
133138
134139
135- def unregister_sighups (instance_id : str ) -> None :
140+ def unregister_sighups (homeserver_instance_id : str ) -> None :
136141 """
137142 Unregister all sighup functions associated with this Synapse instance.
138143
139144 Args:
140- instance_id: Unique ID for this Synapse process instance.
145+ homeserver_instance_id: The unique ID for this Synapse process instance to
146+ unregister hooks for (`hs.get_instance_id()`).
141147 """
142- _instance_id_to_sighup_callbacks_map .pop (instance_id , [])
148+ _instance_id_to_sighup_callbacks_map .pop (homeserver_instance_id , [])
143149
144150
145151def start_worker_reactor (
@@ -639,8 +645,8 @@ async def start(hs: "HomeServer", freeze: bool = True) -> None:
639645 )
640646
641647 setup_sighup_handling ()
642- register_sighup (hs . get_instance_id () , refresh_certificate , hs )
643- register_sighup (hs . get_instance_id () , reload_cache_config , hs .config )
648+ register_sighup (hs , refresh_certificate , hs )
649+ register_sighup (hs , reload_cache_config , hs .config )
644650
645651 # Apply the cache config.
646652 hs .config .caches .resize_all_caches ()
0 commit comments