mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-30 19:02:34 +00:00
WIP
This commit is contained in:
parent
63c60b2c1f
commit
82975e31c8
3 changed files with 30 additions and 20 deletions
|
@ -60,6 +60,20 @@ def authenticate(actual_method):
|
|||
return wrapper
|
||||
|
||||
|
||||
class Shutdown(Resource):
|
||||
@authenticate
|
||||
def get(self):
|
||||
from main import doShutdown
|
||||
doShutdown()
|
||||
|
||||
|
||||
class Restart(Resource):
|
||||
@authenticate
|
||||
def get(self):
|
||||
from main import doRestart
|
||||
doRestart()
|
||||
|
||||
|
||||
class Badges(Resource):
|
||||
@authenticate
|
||||
def get(self):
|
||||
|
@ -1218,6 +1232,9 @@ class SearchWantedMovies(Resource):
|
|||
return '', 200
|
||||
|
||||
|
||||
api.add_resource(Shutdown, '/shutdown')
|
||||
api.add_resource(Restart, '/restart')
|
||||
|
||||
api.add_resource(Badges, '/badges')
|
||||
api.add_resource(Languages, '/languages')
|
||||
|
||||
|
|
|
@ -168,12 +168,6 @@ def logout():
|
|||
return redirect(url_for('redirect_root'))
|
||||
|
||||
|
||||
@app.route('/shutdown/')
|
||||
@login_required
|
||||
def shutdown():
|
||||
doShutdown()
|
||||
|
||||
|
||||
def doShutdown():
|
||||
try:
|
||||
server.close()
|
||||
|
@ -186,15 +180,13 @@ def doShutdown():
|
|||
except Exception as e:
|
||||
logging.error('BAZARR Cannot create bazarr.stop file.')
|
||||
else:
|
||||
logging.info('Bazarr is being shutdown...')
|
||||
stop_file.write(str(''))
|
||||
stop_file.close()
|
||||
os._exit(0)
|
||||
return ''
|
||||
|
||||
|
||||
@app.route('/restart/')
|
||||
@login_required
|
||||
def restart():
|
||||
def doRestart():
|
||||
try:
|
||||
server.close()
|
||||
except:
|
||||
|
@ -210,7 +202,6 @@ def restart():
|
|||
restart_file.write(str(''))
|
||||
restart_file.close()
|
||||
os._exit(0)
|
||||
return ''
|
||||
|
||||
|
||||
@app.route('/wizard/')
|
||||
|
@ -722,10 +713,12 @@ else:
|
|||
server = create_server(app,
|
||||
host=str(settings.general.ip),
|
||||
port=int(args.port) if args.port else int(settings.general.port))
|
||||
try:
|
||||
logging.info('BAZARR is started and waiting for request on http://' + str(settings.general.ip) + ':' + (str(
|
||||
args.port) if args.port else str(settings.general.port)) + str(base_url))
|
||||
if not args.dev:
|
||||
server.run()
|
||||
except KeyboardInterrupt:
|
||||
doShutdown()
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
logging.info('BAZARR is started and waiting for request on http://' + str(settings.general.ip) + ':' + (str(
|
||||
args.port) if args.port else str(settings.general.port)) + str(base_url))
|
||||
if not args.dev:
|
||||
server.run()
|
||||
except KeyboardInterrupt:
|
||||
doShutdown()
|
||||
|
|
|
@ -401,7 +401,7 @@
|
|||
$('#loader_text').text("Bazarr is restarting, please wait...");
|
||||
$('#reconnect_overlay').show();
|
||||
$.ajax({
|
||||
url: "{{ url_for('restart') }}"
|
||||
url: "{{ url_for('api.restart') }}"
|
||||
})
|
||||
setTimeout(function () {
|
||||
setInterval(ping, 2000);
|
||||
|
@ -422,7 +422,7 @@
|
|||
document.write('Bazarr has shutdown.');
|
||||
document.close();
|
||||
$.ajax({
|
||||
url: "{{ url_for('shutdown') }}",
|
||||
url: "{{ url_for('api.shutdown') }}",
|
||||
async: true
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue