This is an automated email from the ASF dual-hosted git repository.

assafpinhasi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-liminal.git


The following commit(s) were added to refs/heads/master by this push:
     new be49a3b  add liminal stop and logs
     new 70df701  Merge pull request #1 from 
naturalett/naturalett/adding-liminal-stop-button
be49a3b is described below

commit be49a3b6e23fc4bee40c041173ab3d73b8efd7b8
Author: lidor ettinger <[email protected]>
AuthorDate: Wed Nov 18 12:15:58 2020 +0100

    add liminal stop and logs
---
 README.md       | 22 +++++++++++++++++++---
 scripts/liminal | 36 +++++++++++++++++++++++++++++++-----
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 589e6e5..d1357fa 100644
--- a/README.md
+++ b/README.md
@@ -162,12 +162,28 @@ This will rebuild the airlfow docker containers from 
scratch with a fresh versio
 liminal start
 ```
 
-5. Navigate to [http://localhost:8080/admin](http://localhost:8080/admin)
+5. Stop the server
+```bash
+liminal stop
+```
+
+6. Display the server logs
+```bash
+liminal logs --follow/--tail
+
+Number of lines to show from the end of the log:
+liminal logs --tail=10
+
+Follow log output:
+liminal logs --follow
+```
+
+6. Navigate to [http://localhost:8080/admin](http://localhost:8080/admin)
 
-6. You should see your 
![pipeline](https://raw.githubusercontent.com/apache/incubator-liminal/master/images/airflow.png)
+7. You should see your 
![pipeline](https://raw.githubusercontent.com/apache/incubator-liminal/master/images/airflow.png)
 The pipeline is scheduled to run according to the ```json schedule: 0 * 1 * 
*``` field in the .yml file you provided.
 
-7. To manually activate your pipeline:
+8. To manually activate your pipeline:
 Click your pipeline and then click "trigger DAG"
 Click "Graph view"
 You should see the steps in your pipeline getting executed in "real time" by 
clicking "Refresh" periodically.
diff --git a/scripts/liminal b/scripts/liminal
index 4476004..0a794b5 100755
--- a/scripts/liminal
+++ b/scripts/liminal
@@ -84,9 +84,12 @@ def deploy_liminal_core_internal(clean):
 def docker_compose_command(command_name, args):
     docker_compose_path, project_dir = get_docker_compose_paths()
     concated_args = ' '.join(args)
-    subprocess.call(
-        [f'docker-compose -f "{docker_compose_path}" -p liminal 
--project-directory {project_dir} {command_name} {concated_args}'],
-        env=os.environ, shell=True)
+    run_command = [f'docker-compose -f "{docker_compose_path}" -p liminal 
--project-directory {project_dir} {command_name} {concated_args}']
+    if 'follow' in str(args):
+        subprocess.call(run_command, env=os.environ, shell=True)
+    else:
+        output = subprocess.run(run_command,env=os.environ, shell=True, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+    return output.stdout, output.stderr
 
 @cli.command("deploy", short_help="deploys your liminal.yaml files to 
$LIMINAL_HOME folder")
 @click.option('--path', default=os.getcwd(), help="folder containing 
liminal.yaml files")
@@ -104,6 +107,29 @@ def deploy_liminal_apps(path, clean):
         target_yml_name = os.path.join(environment.get_dags_dir(), yml_name)
         shutil.copyfile(config_file, target_yml_name)
 
+def liminal_is_running():
+        stdout, stderr = docker_compose_command('ps', [])
+        return "liminal" in stdout
+
[email protected]("stop", short_help="stops the docker compose")
+def stop():
+    if docker_is_running() and liminal_is_running():
+        # initialize liminal home by default
+        environment.get_liminal_home()
+        docker_compose_command('down', [])
+
[email protected]("logs", short_help="display the docker compose logs")
[email protected]('--follow', '-f', is_flag=True, default=False, help="Follow log 
output.")
[email protected]('--tail', '-t', default=0, type=int, help="Number of lines to 
show from the end of the log")
+def logs(follow, tail):
+    if docker_is_running() and liminal_is_running():
+        # initialize liminal home by default
+        environment.get_liminal_home()
+        if (follow):
+                docker_compose_command('logs', ['--follow'])
+        if (tail>0):
+                stdout, stderr = docker_compose_command('logs', 
[f'--tail={tail}'])
+                print(stdout)
 
 @cli.command("start",
              short_help="starts a local airflow in docker compose. should be 
run after deploy. " +
@@ -113,7 +139,7 @@ def start():
         # initialize liminal home by default
         environment.get_liminal_home()
         docker_compose_path, project_dir = get_docker_compose_paths()
-        docker_compose_command('up', [])
+        docker_compose_command('up', ['-d'])
 
 
 def get_docker_compose_paths():
@@ -125,4 +151,4 @@ def get_docker_compose_paths():
 
 
 if __name__ == '__main__':
-    cli()
\ No newline at end of file
+    cli()

Reply via email to