mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 02:27:19 -04:00 
			
		
		
		
	Add hook for instance startup (#1888)
Provides a new hook for plugins as a means to provide the current caddy.Instance when starting or restarting.
This commit is contained in:
		
							parent
							
								
									f878247a18
								
							
						
					
					
						commit
						97710ced7e
					
				
							
								
								
									
										3
									
								
								caddy.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								caddy.go
									
									
									
									
									
								
							| @ -213,6 +213,9 @@ func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) { | |||||||
| 	} | 	} | ||||||
| 	i.Stop() | 	i.Stop() | ||||||
| 
 | 
 | ||||||
|  | 	// Execute instantiation events | ||||||
|  | 	EmitEvent(InstanceStartupEvent, newInst) | ||||||
|  | 
 | ||||||
| 	log.Println("[INFO] Reloading complete") | 	log.Println("[INFO] Reloading complete") | ||||||
| 
 | 
 | ||||||
| 	return newInst, nil | 	return newInst, nil | ||||||
|  | |||||||
| @ -140,6 +140,9 @@ func Run() { | |||||||
| 		mustLogFatalf("%v", err) | 		mustLogFatalf("%v", err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	// Execute instantiation events | ||||||
|  | 	caddy.EmitEvent(caddy.InstanceStartupEvent, instance) | ||||||
|  | 
 | ||||||
| 	// Twiddle your thumbs | 	// Twiddle your thumbs | ||||||
| 	instance.Wait() | 	instance.Wait() | ||||||
| } | } | ||||||
|  | |||||||
| @ -236,6 +236,7 @@ const ( | |||||||
| 	StartupEvent         EventName = "startup" | 	StartupEvent         EventName = "startup" | ||||||
| 	ShutdownEvent        EventName = "shutdown" | 	ShutdownEvent        EventName = "shutdown" | ||||||
| 	CertRenewEvent       EventName = "certrenew" | 	CertRenewEvent       EventName = "certrenew" | ||||||
|  | 	InstanceStartupEvent EventName = "instancestartup" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // EventHook is a type which holds information about a startup hook plugin. | // EventHook is a type which holds information about a startup hook plugin. | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user