mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-04-17 23:56:29 +03:00
Handle SIGINT/SIGTERM, close database descriptior (fixes #5)
This commit is contained in:
@@ -13,6 +13,7 @@ type SQLite3Storage struct {
|
||||
*TableMailboxes
|
||||
*TableMails
|
||||
*TableQueue
|
||||
db *sql.DB
|
||||
writer *Writer
|
||||
}
|
||||
|
||||
@@ -22,6 +23,7 @@ func NewSQLite3StorageStorage(filename string) (*SQLite3Storage, error) {
|
||||
return nil, fmt.Errorf("sql.Open: %w", err)
|
||||
}
|
||||
s := &SQLite3Storage{
|
||||
db: db,
|
||||
writer: &Writer{
|
||||
todo: make(chan writerTask),
|
||||
},
|
||||
@@ -45,6 +47,10 @@ func NewSQLite3StorageStorage(filename string) (*SQLite3Storage, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (s *SQLite3Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
type Writer struct {
|
||||
running atomic.Bool
|
||||
todo chan writerTask
|
||||
|
||||
Reference in New Issue
Block a user