For Docker, log output to a file (unrotated !) (#1228)
* For Docker, log output to a file (unrotated !) * Rotate Docker output log if it exceeds 4MB
This commit is contained in:
		
					parent
					
						
							
								282cc0ddd3
							
						
					
				
			
			
				commit
				
					
						bfd89e87b3
					
				
			
		
					 1 changed files with 11 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,6 +28,10 @@ if [ ! -f "${nanodir}/config.json" ]; then
 | 
				
			||||||
        cp "/usr/share/nano/config/${network}.json" "${nanodir}/config.json"
 | 
					        cp "/usr/share/nano/config/${network}.json" "${nanodir}/config.json"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Start watching the log file we are going to log output to
 | 
				
			||||||
 | 
					logfile="${nanodir}/nano-docker-output.log"
 | 
				
			||||||
 | 
					tail -F "${logfile}" &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pid=''
 | 
					pid=''
 | 
				
			||||||
firstTimeComplete=''
 | 
					firstTimeComplete=''
 | 
				
			||||||
while true; do
 | 
					while true; do
 | 
				
			||||||
| 
						 | 
					@ -62,4 +66,10 @@ while true; do
 | 
				
			||||||
		nano_node --daemon &
 | 
							nano_node --daemon &
 | 
				
			||||||
		pid="$!"
 | 
							pid="$!"
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
done
 | 
					
 | 
				
			||||||
 | 
						if [ "$(stat -c '%s' "${logfile}")" -gt 4194304 ]; then
 | 
				
			||||||
 | 
							cp "${logfile}" "${logfile}.old"
 | 
				
			||||||
 | 
							: > "${logfile}"
 | 
				
			||||||
 | 
							echo "$(date) Rotated log file"
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					done >> "${logfile}" 2>&1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue