MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / Close

Method Close

application/application.go:182–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180}
181
182func (s *server) Close() {
183 if s.dbClient != nil {
184 s.logger.Info("Shutting down database connection...")
185 if err := s.dbClient.Close(); err != nil {
186 s.logger.Error("Failed to close database connection: %s", err)
187 }
188 }
189
190 ctx := context.Background()
191 if conf.SystemConfig.GracePeriod != 0 {
192 var cancel context.CancelFunc
193 ctx, cancel = context.WithTimeout(ctx, time.Duration(s.config.System().GracePeriod)*time.Second)
194 defer cancel()
195 }
196
197 s.dep.EventHub().Close()
198
199 // Shutdown http server
200 if s.server != nil {
201 err := s.server.Shutdown(ctx)
202 if err != nil {
203 s.logger.Error("Failed to shutdown server: %s", err)
204 }
205 }
206
207 // Shutdown pprof server
208 if s.pprofServer != nil {
209 if err := s.pprofServer.Shutdown(ctx); err != nil {
210 s.logger.Error("Failed to shutdown pprof server: %s", err)
211 }
212 }
213
214 if s.kv != nil {
215 if err := s.kv.Persist(util.DataPath(cache.DefaultCacheFile)); err != nil {
216 s.logger.Warning("Failed to persist cache: %s", err)
217 }
218 }
219
220 if err := s.dep.Shutdown(ctx); err != nil {
221 s.logger.Warning("Failed to shutdown dependency manager: %s", err)
222 }
223}
224
225func (s *server) runUnix(server *http.Server) error {
226 listener, err := net.Listen("unix", s.config.Unix().Listen)

Callers

nothing calls this directly

Calls 9

DataPathFunction · 0.92
InfoMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
SystemMethod · 0.65
EventHubMethod · 0.65
ShutdownMethod · 0.65
PersistMethod · 0.65
WarningMethod · 0.65

Tested by

no test coverage detected