September 2017
Intermediate to advanced
466 pages
9h 33m
English
As I told you back in Chapter 7, Working with System Files, this chapter will present you with a technique that will allow you to end the program and rotate log files in a more conventional way with the help of signals and signal handling.
The name of the new version of rotateLog.go will be rotateSignals.go and will be presented in four parts. Moreover, when the utility receives os.Interrupt, it will rotate the current log file, whereas when it receives syscall.SIGTERM, it will terminate its execution. Every other signal that can be handled will create a log entry without any other action.
The first part of the rotateSignals.go is the expected preamble:
package main import ( "fmt" "log" "os" "os/signal" "strconv" ...
Read now
Unlock full access