File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ local geoip_download_if_missing_or_old = require("api-umbrella.utils.geoip").dow
44local  shell_blocking_capture_combined  =  require (" shell-games"  ).capture_combined 
55local  unistd  =  require  " posix.unistd" 
66
7+ local  sleep  =  ngx .sleep 
8+ 
79local  function  permission_check ()
810  local  effective_uid  =  unistd .geteuid ()
911  if  config [" user"  ] then 
@@ -57,9 +59,20 @@ local function ensure_geoip_db()
5759  config [" geoip"  ][" _enabled"  ] =  false 
5860  config [" geoip"  ][" _auto_updater_enabled"  ] =  false 
5961
60-   local  _ , err  =  geoip_download_if_missing_or_old (config )
61-   if  err  then 
62-     ngx .log (ngx .ERR , " geoip database download failed: "  , err )
62+   --  Try to wait for geoip to download, since there may be race conditions on
63+   --  startup in downloading via http proxy that's also starting up.
64+   local  _ 
65+   local  geoip_err 
66+   local  timeout_at  =  ngx .now () +  60 
67+   repeat 
68+     _ , geoip_err  =  geoip_download_if_missing_or_old (config )
69+     if  geoip_err  then 
70+       sleep (1 )
71+     end 
72+   until  not  geoip_err  or  ngx .now () >  timeout_at 
73+ 
74+   if  geoip_err  then 
75+     ngx .log (ngx .ERR , " geoip database download failed: "  , geoip_err )
6376  else 
6477    config [" geoip"  ][" _enabled"  ] =  true 
6578
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments