예제 #1
0
파일: clock.go 프로젝트: escribano/soju
func (cs *ClockService) StopNow(doneNotifier soju.DoneNotifier) (err error) {

	cs.Logger.Println("Aborted! Must stop all pending requests!")

	cs.Logger.Println("Aborting the service...")
	//Close the log file
	err = cs.LogFile.Close()
	if err != nil {
		return
	}

	cs.Started = false

	doneNotifier.Done()

	return

}
예제 #2
0
파일: clock.go 프로젝트: escribano/soju
func (cs *ClockService) Stop(doneNotifier soju.DoneNotifier) (err error) {

	cs.Logger.Println("Shutdown signal!")

	if !cs.Started {
		return
	}

	cs.Called = true

	cs.Logger.Println("Closing the listener.")
	//Do not accept new requests.
	err = cs.wl.Close()
	if err != nil {
		cs.Logger.Printf("Error closing the listener [%s]", err.Error())
		return
	}

	cs.Logger.Println("Waiting for all pending requests to finish...")
	//Block until all requests are done.
	cs.waitGroup.Wait()

	cs.Logger.Println("Stopping the service...")
	//Close the log file
	err = cs.LogFile.Close()
	if err != nil {
		return
	}

	cs.Started = false

	doneNotifier.Done()

	return

}