Skip to content

Commit

Permalink
change comments with example
Browse files Browse the repository at this point in the history
  • Loading branch information
takama committed Jan 31, 2015
1 parent a589360 commit d8ebc7a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In the current implementation is only supported Linux and Mac Os X daemon.
Example:
//Example of the daemon with echo service
// Example of a daemon with echo service
package main
import (
Expand All @@ -36,6 +36,8 @@ Example:
port = ":9977"
)
var stdlog, errlog *log.Logger
// Service has embedded daemon
type Service struct {
daemon.Daemon
Expand Down Expand Up @@ -90,8 +92,8 @@ Example:
case conn := <-listen:
go handleClient(conn)
case killSignal := <-interrupt:
log.Println("Got signal:", killSignal)
log.Println("Stoping listening on ", listener.Addr())
stdlog.Println("Got signal:", killSignal)
stdlog.Println("Stoping listening on ", listener.Addr())
listener.Close()
if killSignal == os.Interrupt {
return "Daemon was interruped by system signal", nil
Expand Down Expand Up @@ -126,16 +128,21 @@ Example:
}
}
func init() {
stdlog = log.New(os.Stdout, "", log.Ldate|log.Ltime)
errlog = log.New(os.Stderr, "", log.Ldate|log.Ltime)
}
func main() {
srv, err := daemon.New(name, description)
if err != nil {
fmt.Println("Error: ", err)
errlog.Println("Error: ", err)
os.Exit(1)
}
service := &Service{srv}
status, err := service.Manage()
if err != nil {
fmt.Println(status, "\nError: ", err)
errlog.Println(status, "\nError: ", err)
os.Exit(1)
}
fmt.Println(status)
Expand Down

0 comments on commit d8ebc7a

Please sign in to comment.