From 25a8daa31ff6de0eb0338dcc9607aa680f7677af Mon Sep 17 00:00:00 2001 From: Marius Date: Thu, 6 Apr 2023 19:44:52 +0300 Subject: [PATCH 1/3] restart must work even if the app is stopped when called. At the end, the app should be running. --- piku.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/piku.py b/piku.py index 519ed5b..05879db 100755 --- a/piku.py +++ b/piku.py @@ -1155,19 +1155,22 @@ def spawn_worker(app, kind, command, env, ordinal=1): copyfile(available, enabled) - -def do_restart(app): - """Restarts a deployed app""" - +def do_stop(app): config = glob(join(UWSGI_ENABLED, '{}*.ini'.format(app))) if len(config) > 0: - echo("Restarting app '{}'...".format(app), fg='yellow') + echo("Stopping app '{}'...".format(app), fg='yellow') for c in config: remove(c) - spawn_app(app) 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): @@ -1543,16 +1546,8 @@ def cmd_setup_ssh(public_key_file): @argument('app') def cmd_stop(app): """Stop an app, e.g: piku stop """ - app = exit_if_invalid(app) - config = glob(join(UWSGI_ENABLED, '{}*.ini'.format(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') + do_stop(app) # --- Internal commands --- From 4acaaf4eadb2dc4e52a8a4d2f60637a98a2d023f Mon Sep 17 00:00:00 2001 From: Marius A Date: Thu, 6 Apr 2023 19:50:52 +0300 Subject: [PATCH 2/3] fix lint spaces --- piku.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/piku.py b/piku.py index 05879db..344be91 100755 --- a/piku.py +++ b/piku.py @@ -1155,6 +1155,7 @@ def spawn_worker(app, kind, command, env, ordinal=1): copyfile(available, enabled) + def do_stop(app): config = glob(join(UWSGI_ENABLED, '{}*.ini'.format(app))) @@ -1163,11 +1164,12 @@ def do_stop(app): for c in config: remove(c) else: - echo("Error: app '{}' not deployed!".format(app), fg='red') # TODO app could be already stopped. Need to able to tell the difference. + 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""" + # This must work even if the app is stopped when called. At the end, the app should be running. echo("restarting app '{}'...".format(app), fg='yellow') do_stop(app) spawn_app(app) From e02b745529a86f9f34d7a950b947b38bdcd03d8f Mon Sep 17 00:00:00 2001 From: Marius A Date: Thu, 6 Apr 2023 19:55:08 +0300 Subject: [PATCH 3/3] fix lint space --- piku.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piku.py b/piku.py index 344be91..d781196 100755 --- a/piku.py +++ b/piku.py @@ -1170,7 +1170,7 @@ def do_stop(app): def do_restart(app): """Restarts a deployed app""" # This must work even if the app is stopped when called. At the end, the app should be running. - echo("restarting app '{}'...".format(app), fg='yellow') + echo("restarting app '{}'...".format(app), fg='yellow') do_stop(app) spawn_app(app)