mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	Remove pidfile when program exits (closes #495)
This commit is contained in:
		
							parent
							
								
									dab679df86
								
							
						
					
					
						commit
						0830c728fe
					
				| @ -32,10 +32,18 @@ func trapSignalsCrossPlatform() { | ||||
| 
 | ||||
| 			if i > 0 { | ||||
| 				log.Println("[INFO] SIGINT: Force quit") | ||||
| 				if PidFile != "" { | ||||
| 					os.Remove(PidFile) | ||||
| 				} | ||||
| 				os.Exit(1) | ||||
| 			} | ||||
| 
 | ||||
| 			log.Println("[INFO] SIGINT: Shutting down") | ||||
| 
 | ||||
| 			if PidFile != "" { | ||||
| 				os.Remove(PidFile) | ||||
| 			} | ||||
| 
 | ||||
| 			go os.Exit(executeShutdownCallbacks("SIGINT")) | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| @ -20,6 +20,9 @@ func trapSignalsPosix() { | ||||
| 			switch sig { | ||||
| 			case syscall.SIGTERM: | ||||
| 				log.Println("[INFO] SIGTERM: Terminating process") | ||||
| 				if PidFile != "" { | ||||
| 					os.Remove(PidFile) | ||||
| 				} | ||||
| 				os.Exit(0) | ||||
| 
 | ||||
| 			case syscall.SIGQUIT: | ||||
| @ -30,6 +33,9 @@ func trapSignalsPosix() { | ||||
| 					log.Printf("[ERROR] SIGQUIT stop: %v", err) | ||||
| 					exitCode = 1 | ||||
| 				} | ||||
| 				if PidFile != "" { | ||||
| 					os.Remove(PidFile) | ||||
| 				} | ||||
| 				os.Exit(exitCode) | ||||
| 
 | ||||
| 			case syscall.SIGHUP: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user