Browse Source

filer: close stores if interrupted

pull/1255/head
Chris Lu 5 years ago
parent
commit
7b37178716
  1. 4
      weed/filer2/abstract_sql/abstract_sql_store.go
  2. 4
      weed/filer2/cassandra/cassandra_store.go
  3. 4
      weed/filer2/etcd/etcd_store.go
  4. 4
      weed/filer2/filer.go
  5. 6
      weed/filer2/filerstore.go
  6. 4
      weed/filer2/leveldb/leveldb_store.go
  7. 6
      weed/filer2/leveldb2/leveldb2_store.go
  8. 5
      weed/filer2/redis/universal_redis_store.go
  9. 4
      weed/server/filer_server.go

4
weed/filer2/abstract_sql/abstract_sql_store.go

@ -184,3 +184,7 @@ func (store *AbstractSqlStore) ListDirectoryEntries(ctx context.Context, fullpat
return entries, nil
}
func (store *AbstractSqlStore) Shutdown() {
store.DB.Close()
}

4
weed/filer2/cassandra/cassandra_store.go

@ -154,3 +154,7 @@ func (store *CassandraStore) ListDirectoryEntries(ctx context.Context, fullpath
return entries, err
}
func (store *CassandraStore) Shutdown() {
store.session.Close()
}

4
weed/filer2/etcd/etcd_store.go

@ -196,3 +196,7 @@ func getNameFromKey(key []byte) string {
return string(key[sepIndex+1:])
}
func (store *EtcdStore) Shutdown() {
store.client.Close()
}

4
weed/filer2/filer.go

@ -308,3 +308,7 @@ func (f *Filer) cacheSetDirectory(dirpath string, dirEntry *Entry, level int) {
f.directoryCache.Set(dirpath, dirEntry, time.Duration(minutes)*time.Minute)
}
func (f *Filer) Shutdown() {
f.store.Shutdown()
}

6
weed/filer2/filerstore.go

@ -25,6 +25,8 @@ type FilerStore interface {
BeginTransaction(ctx context.Context) (context.Context, error)
CommitTransaction(ctx context.Context) error
RollbackTransaction(ctx context.Context) error
Shutdown()
}
type FilerStoreWrapper struct {
@ -133,3 +135,7 @@ func (fsw *FilerStoreWrapper) CommitTransaction(ctx context.Context) error {
func (fsw *FilerStoreWrapper) RollbackTransaction(ctx context.Context) error {
return fsw.actualStore.RollbackTransaction(ctx)
}
func (fsw *FilerStoreWrapper) Shutdown() {
fsw.actualStore.Shutdown()
}

4
weed/filer2/leveldb/leveldb_store.go

@ -216,3 +216,7 @@ func getNameFromKey(key []byte) string {
return string(key[sepIndex+1:])
}
func (store *LevelDBStore) Shutdown() {
store.db.Close()
}

6
weed/filer2/leveldb2/leveldb2_store.go

@ -236,3 +236,9 @@ func hashToBytes(dir string, dbCount int) ([]byte, int) {
return b, int(x) % dbCount
}
func (store *LevelDB2Store) Shutdown() {
for d := 0; d < store.dbCount; d++ {
store.dbs[d].Close()
}
}

5
weed/filer2/redis/universal_redis_store.go

@ -180,3 +180,8 @@ func (store *UniversalRedisStore) ListDirectoryEntries(ctx context.Context, full
func genDirectoryListKey(dir string) (dirList string) {
return dir + DIR_LIST_MARKER
}
func (store *UniversalRedisStore) Shutdown() {
store.Client.Close()
}

4
weed/server/filer_server.go

@ -102,6 +102,10 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
maybeStartMetrics(fs, option)
util.OnInterrupt(func() {
fs.filer.Shutdown()
})
return fs, nil
}

Loading…
Cancel
Save