restart must work even if the app is stopped when called. At the end, the app should be running.

pull/301/head
Marius 2023-04-06 19:44:52 +03:00
rodzic 4306aad22a
commit 25a8daa31f
1 zmienionych plików z 11 dodań i 16 usunięć

27
piku.py
Wyświetl plik

@ -1155,19 +1155,22 @@ def spawn_worker(app, kind, command, env, ordinal=1):
copyfile(available, enabled) copyfile(available, enabled)
def do_stop(app):
def do_restart(app):
"""Restarts a deployed app"""
config = glob(join(UWSGI_ENABLED, '{}*.ini'.format(app))) config = glob(join(UWSGI_ENABLED, '{}*.ini'.format(app)))
if len(config) > 0: if len(config) > 0:
echo("Restarting app '{}'...".format(app), fg='yellow') echo("Stopping app '{}'...".format(app), fg='yellow')
for c in config: for c in config:
remove(c) remove(c)
spawn_app(app)
else: else:
echo("Error: app '{}' not deployed!".format(app), fg='red') echo("Error: app '{}' not deployed!".format(app), fg='red') # TODO app could be already stopped. Need to able to tell the difference.
# This must work even if the app is stopped when called. At the end, the app should be running.
def do_restart(app):
"""Restarts a deployed app"""
echo("restarting app '{}'...".format(app), fg='yellow')
do_stop(app)
spawn_app(app)
def multi_tail(app, filenames, catch_up=20): def multi_tail(app, filenames, catch_up=20):
@ -1543,16 +1546,8 @@ def cmd_setup_ssh(public_key_file):
@argument('app') @argument('app')
def cmd_stop(app): def cmd_stop(app):
"""Stop an app, e.g: piku stop <app>""" """Stop an app, e.g: piku stop <app>"""
app = exit_if_invalid(app) app = exit_if_invalid(app)
config = glob(join(UWSGI_ENABLED, '{}*.ini'.format(app))) do_stop(app)
if len(config) > 0:
echo("Stopping app '{}'...".format(app), fg='yellow')
for c in config:
remove(c)
else:
echo("Error: app '{}' not deployed!".format(app), fg='red')
# --- Internal commands --- # --- Internal commands ---