Handle server restarts gracefully