mirror of
				https://github.com/nadoo/glider.git
				synced 2025-11-04 07:42:38 +08:00 
			
		
		
		
	Setrlimit in linux
This commit is contained in:
		
							parent
							
								
									e6f1c8928e
								
							
						
					
					
						commit
						e52c0f814e
					
				
							
								
								
									
										25
									
								
								common/utils/utils_linux.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								common/utils/utils_linux.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					// +build linux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"syscall"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/nadoo/glider/common/log"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func InitRLimit() {
 | 
				
			||||||
 | 
						var rlim syscall.Rlimit
 | 
				
			||||||
 | 
						err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.F("get rlimit error: " + err.Error())
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						rlim.Cur = 1048576
 | 
				
			||||||
 | 
						rlim.Max = 1048576
 | 
				
			||||||
 | 
						err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.F("set rlimit error: " + err.Error())
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										7
									
								
								common/utils/utils_linux_other.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								common/utils/utils_linux_other.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					// +build !linux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func InitRLimit() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										3
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								main.go
									
									
									
									
									
								
							@ -7,6 +7,7 @@ import (
 | 
				
			|||||||
	"syscall"
 | 
						"syscall"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/nadoo/glider/common/log"
 | 
						"github.com/nadoo/glider/common/log"
 | 
				
			||||||
 | 
						"github.com/nadoo/glider/common/utils"
 | 
				
			||||||
	"github.com/nadoo/glider/dns"
 | 
						"github.com/nadoo/glider/dns"
 | 
				
			||||||
	"github.com/nadoo/glider/ipset"
 | 
						"github.com/nadoo/glider/ipset"
 | 
				
			||||||
	"github.com/nadoo/glider/proxy"
 | 
						"github.com/nadoo/glider/proxy"
 | 
				
			||||||
@ -46,6 +47,8 @@ func main() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						utils.InitRLimit()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// global rule dialer
 | 
						// global rule dialer
 | 
				
			||||||
	dialer := rule.NewDialer(conf.rules, strategy.NewDialer(conf.Forward, &conf.StrategyConfig))
 | 
						dialer := rule.NewDialer(conf.rules, strategy.NewDialer(conf.Forward, &conf.StrategyConfig))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user