mirror of
				https://github.com/terorie/od-database-crawler.git
				synced 2025-10-31 05:16:52 +00:00 
			
		
		
		
	Add recheck and timeout parameters
This commit is contained in:
		
							parent
							
								
									339175220d
								
							
						
					
					
						commit
						4464f34779
					
				| @ -12,6 +12,8 @@ import ( | ||||
| var config struct { | ||||
| 	ServerUrl  string | ||||
| 	Token      string | ||||
| 	ServerTimeout time.Duration | ||||
| 	Recheck    time.Duration | ||||
| 	ChunkSize  uint | ||||
| 	Retries    int | ||||
| 	Workers    int | ||||
| @ -26,6 +28,8 @@ var config struct { | ||||
| const ( | ||||
| 	ConfServerUrl  = "server.url" | ||||
| 	ConfToken      = "server.token" | ||||
| 	ConfServerTimeout = "server.timeout" | ||||
| 	ConfRecheck    = "server.recheck" | ||||
| 	ConfChunkSize  = "server.upload_chunk" | ||||
| 	ConfTasks      = "crawl.tasks" | ||||
| 	ConfRetries    = "crawl.retries" | ||||
| @ -46,6 +50,7 @@ func prepareConfig() { | ||||
| 	viper.SetDefault(ConfAllocStats, 0) | ||||
| 	viper.SetDefault(ConfVerbose, false) | ||||
| 	viper.SetDefault(ConfPrintHTTP, false) | ||||
| 	viper.SetDefault(ConfRecheck, 3 * time.Second) | ||||
| 	viper.SetDefault(ConfChunkSize, "1 MB") | ||||
| } | ||||
| 
 | ||||
| @ -69,6 +74,10 @@ func readConfig() { | ||||
| 		configMissing(ConfToken) | ||||
| 	} | ||||
| 
 | ||||
| 	config.ServerTimeout = viper.GetDuration(ConfServerTimeout) | ||||
| 
 | ||||
| 	config.Recheck = viper.GetDuration(ConfRecheck) | ||||
| 
 | ||||
| 	config.ChunkSize = viper.GetSizeInBytes(ConfChunkSize) | ||||
| 	if config.ChunkSize < 100 { | ||||
| 		configOOB(ConfChunkSize, config.ChunkSize) | ||||
|  | ||||
							
								
								
									
										11
									
								
								config.yml
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								config.yml
									
									
									
									
									
								
							| @ -2,8 +2,19 @@ | ||||
| server: | ||||
|   # Connection URL | ||||
|   url: http://od-db.mine.terorie.com/api | ||||
| 
 | ||||
|   # Server auth token | ||||
|   token: | ||||
| 
 | ||||
|   # Request timeout | ||||
|   timeout: 60s | ||||
| 
 | ||||
|   # Recheck interval | ||||
|   # The crawler periodically asks the server | ||||
|   # for new jobs. Sets the minimum wait time | ||||
|   # between /task/get requests to the server. | ||||
|   recheck: 1s | ||||
| 
 | ||||
|   # Upload chunk size | ||||
|   # If the value is too high, the upload fails. | ||||
|   upload_chunk: 1 MB | ||||
|  | ||||
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							| @ -59,7 +59,7 @@ func cmdBase(_ *cli.Context) error { | ||||
| 	inRemotes := make(chan *OD) | ||||
| 	go Schedule(forceCtx, inRemotes) | ||||
| 
 | ||||
| 	ticker := time.NewTicker(3 * time.Second) | ||||
| 	ticker := time.NewTicker(config.Recheck) | ||||
| 	defer ticker.Stop() | ||||
| 	for { | ||||
| 		select { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user