mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	"-conf stdin" required to pipe in Caddyfile
Some programs (Node.js, supervisor, etc.) open a stdin pipe by default and don't use it, causing Caddy to block. It is their error, but we have to try to accommodate unfortunately. To fix this more universally, parent must explicitly set -conf to "stdin" to read from pipe.
This commit is contained in:
		
							parent
							
								
									c31e86db02
								
							
						
					
					
						commit
						e9b9432da5
					
				
							
								
								
									
										20
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								main.go
									
									
									
									
									
								
							@ -117,25 +117,17 @@ func mustLogFatal(args ...interface{}) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func loadCaddyfile() (caddy.Input, error) {
 | 
					func loadCaddyfile() (caddy.Input, error) {
 | 
				
			||||||
	// First try stdin pipe
 | 
						// Try -conf flag
 | 
				
			||||||
	cdyfile, err := caddy.CaddyfileFromPipe(os.Stdin)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if cdyfile != nil {
 | 
					 | 
				
			||||||
		// it is an error if -conf is also specified because, which to use?
 | 
					 | 
				
			||||||
		if conf != "" {
 | 
					 | 
				
			||||||
			return nil, errors.New("load: can't choose between stdin pipe and -conf flag")
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return cdyfile, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// -conf flag
 | 
					 | 
				
			||||||
	if conf != "" {
 | 
						if conf != "" {
 | 
				
			||||||
 | 
							if conf == "stdin" {
 | 
				
			||||||
 | 
								return caddy.CaddyfileFromPipe(os.Stdin)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		contents, err := ioutil.ReadFile(conf)
 | 
							contents, err := ioutil.ReadFile(conf)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return caddy.CaddyfileInput{
 | 
							return caddy.CaddyfileInput{
 | 
				
			||||||
			Contents: contents,
 | 
								Contents: contents,
 | 
				
			||||||
			Filepath: conf,
 | 
								Filepath: conf,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user