mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-27 18:17:46 +00:00
Continuing development.
This commit is contained in:
parent
35ea0775a5
commit
47dd76fced
2 changed files with 18 additions and 10 deletions
|
@ -4,17 +4,20 @@ import atexit
|
||||||
from get_args import args
|
from get_args import args
|
||||||
from peewee import *
|
from peewee import *
|
||||||
from playhouse.sqliteq import SqliteQueueDatabase
|
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
|
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
|
||||||
|
|
||||||
database = SqliteQueueDatabase(
|
database = SqliteQueueDatabase(
|
||||||
os.path.join(args.config_dir, 'db', 'bazarr.db'),
|
os.path.join(args.config_dir, 'db', 'bazarr.db'),
|
||||||
use_gevent=False, # Use the standard library "threading" module.
|
use_gevent=False,
|
||||||
autostart=False, # The worker thread now must be started manually.
|
autostart=True,
|
||||||
queue_max_size=256, # Max. # of pending writes that can accumulate.
|
queue_max_size=256, # Max. # of pending writes that can accumulate.
|
||||||
results_timeout=30.0) # Max. time to wait for query to be executed.
|
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')
|
@database.func('path_substitution')
|
||||||
def path_substitution(path):
|
def path_substitution(path):
|
||||||
|
@ -168,13 +171,7 @@ class TableSettingsNotifier(BaseModel):
|
||||||
table_name = 'table_settings_notifier'
|
table_name = 'table_settings_notifier'
|
||||||
|
|
||||||
|
|
||||||
@atexit.register
|
|
||||||
def _stop_worker_threads():
|
|
||||||
database.stop()
|
|
||||||
|
|
||||||
|
|
||||||
def database_init():
|
def database_init():
|
||||||
database.start()
|
|
||||||
database.connect()
|
database.connect()
|
||||||
|
|
||||||
models_list = [TableShows, TableEpisodes, TableMovies, TableHistory, TableHistoryMovie, TableSettingsLanguages,
|
models_list = [TableShows, TableEpisodes, TableMovies, TableHistory, TableHistoryMovie, TableSettingsLanguages,
|
||||||
|
@ -190,3 +187,9 @@ def database_init():
|
||||||
System.configured: 0
|
System.configured: 0
|
||||||
}
|
}
|
||||||
).execute()
|
).execute()
|
||||||
|
|
||||||
|
|
||||||
|
@atexit.register
|
||||||
|
def _stop_worker_threads():
|
||||||
|
database.close()
|
||||||
|
database.stop()
|
||||||
|
|
|
@ -22,7 +22,7 @@ import operator
|
||||||
|
|
||||||
from get_args import args
|
from get_args import args
|
||||||
from init import *
|
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
|
TableSettingsLanguages, TableSettingsNotifier, System
|
||||||
|
|
||||||
# Initiate database
|
# Initiate database
|
||||||
|
@ -187,7 +187,10 @@ def shutdown():
|
||||||
else:
|
else:
|
||||||
stop_file.write('')
|
stop_file.write('')
|
||||||
stop_file.close()
|
stop_file.close()
|
||||||
|
database.close()
|
||||||
|
database.stop()
|
||||||
server.stop()
|
server.stop()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
@route(base_url + 'restart')
|
@route(base_url + 'restart')
|
||||||
|
@ -206,6 +209,8 @@ def restart():
|
||||||
logging.info('Bazarr is being restarted...')
|
logging.info('Bazarr is being restarted...')
|
||||||
restart_file.write('')
|
restart_file.write('')
|
||||||
restart_file.close()
|
restart_file.close()
|
||||||
|
database.close()
|
||||||
|
database.stop()
|
||||||
|
|
||||||
|
|
||||||
@route(base_url + 'wizard')
|
@route(base_url + 'wizard')
|
||||||
|
|
Loading…
Reference in a new issue