Continuing development.

pull/543/head
Louis Vézina 5 years ago
parent 35ea0775a5
commit 47dd76fced

@ -4,17 +4,20 @@ import atexit
from get_args import args
from peewee import *
from playhouse.sqliteq import SqliteQueueDatabase
from playhouse.reflection import generate_models
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
database = SqliteQueueDatabase(
os.path.join(args.config_dir, 'db', 'bazarr.db'),
use_gevent=False, # Use the standard library "threading" module.
autostart=False, # The worker thread now must be started manually.
use_gevent=False,
autostart=True,
queue_max_size=256, # Max. # of pending writes that can accumulate.
results_timeout=30.0) # Max. time to wait for query to be executed.
#database = SqliteDatabase(os.path.join(args.config_dir, 'db', 'bazarr.db'), pragmas={
# 'journal_mode': 'wal',
# 'cache_size': -1024 * 8})
@database.func('path_substitution')
def path_substitution(path):
@ -168,13 +171,7 @@ class TableSettingsNotifier(BaseModel):
table_name = 'table_settings_notifier'
@atexit.register
def _stop_worker_threads():
database.stop()
def database_init():
database.start()
database.connect()
models_list = [TableShows, TableEpisodes, TableMovies, TableHistory, TableHistoryMovie, TableSettingsLanguages,
@ -190,3 +187,9 @@ def database_init():
System.configured: 0
}
).execute()
@atexit.register
def _stop_worker_threads():
database.close()
database.stop()

@ -22,7 +22,7 @@ import operator
from get_args import args
from init import *
from database import database_init, TableEpisodes, TableShows, TableMovies, TableHistory, TableHistoryMovie, \
from database import database, database_init, TableEpisodes, TableShows, TableMovies, TableHistory, TableHistoryMovie, \
TableSettingsLanguages, TableSettingsNotifier, System
# Initiate database
@ -187,7 +187,10 @@ def shutdown():
else:
stop_file.write('')
stop_file.close()
database.close()
database.stop()
server.stop()
sys.exit(0)
@route(base_url + 'restart')
@ -206,6 +209,8 @@ def restart():
logging.info('Bazarr is being restarted...')
restart_file.write('')
restart_file.close()
database.close()
database.stop()
@route(base_url + 'wizard')

Loading…
Cancel
Save