@@ -160,11 +160,6 @@ def run_generate_config(environ: Mapping[str, str], ownership: Optional[str]) ->
160160 config_path = environ .get ("SYNAPSE_CONFIG_PATH" , config_dir + "/homeserver.yaml" )
161161 data_dir = environ .get ("SYNAPSE_DATA_DIR" , "/data" )
162162
163- if ownership is not None :
164- # make sure that synapse has perms to write to the data dir.
165- log (f"Setting ownership on { data_dir } to { ownership } " )
166- subprocess .run (["chown" , ownership , data_dir ], check = True )
167-
168163 # create a suitable log config from our template
169164 log_config_file = "%s/%s.log.config" % (config_dir , server_name )
170165 if not os .path .exists (log_config_file ):
@@ -189,9 +184,15 @@ def run_generate_config(environ: Mapping[str, str], ownership: Optional[str]) ->
189184 "--generate-config" ,
190185 "--open-private-ports" ,
191186 ]
187+
188+ if ownership is not None :
189+ # make sure that synapse has perms to write to the data dir.
190+ log (f"Setting ownership on { data_dir } to { ownership } " )
191+ subprocess .run (["chown" , ownership , data_dir ], check = True )
192+ args = ["gosu" , ownership ] + args
193+
192194 # log("running %s" % (args, ))
193- flush_buffers ()
194- os .execv (sys .executable , args )
195+ subprocess .run (args , check = True )
195196
196197
197198def main (args : List [str ], environ : MutableMapping [str , str ]) -> None :
0 commit comments