INNER CODE UNIT · Go

setupGracefulShutdown

photoview/photoview · api/server.go:140

func setupGracefulShutdown(svr *http.Server) {
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM)

	go func() {
		<-c
		log.Println("Shutting down Photoview...")
		ctx, cancel := context.WithTimeout(context.Background(), time.Minute) // Wait for 1m to shutdown
		defer cancel()

		// Shutdown scanners in correct order
		periodic_scanner.ShutdownPeriodicScanner()
		scanner_queue.CloseScannerQueue()

		if err := svr.Shutdown(ctx); err != nil {
			log.Printf("Server shutdown error: %s", err)
		} else {
			log.Println("Shutdown complete")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…