summaryrefslogtreecommitdiff
path: root/tasks.py
diff options
context:
space:
mode:
authorankitjavalkar2018-01-02 14:31:09 +0530
committerankitjavalkar2018-01-04 11:37:21 +0530
commit7d7cc537f908db40ca6f3b10cc2c10d597b2877a (patch)
tree16dd03b257e301e31c8e87281083d3aedb207496 /tasks.py
parentf5bc35996373251d718aa83b3abe1241efc41922 (diff)
downloadonline_test-7d7cc537f908db40ca6f3b10cc2c10d597b2877a.tar.gz
online_test-7d7cc537f908db40ca6f3b10cc2c10d597b2877a.tar.bz2
online_test-7d7cc537f908db40ca6f3b10cc2c10d597b2877a.zip
Add changes as requested in review
Diffstat (limited to 'tasks.py')
-rw-r--r--tasks.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/tasks.py b/tasks.py
index 5e7295a..4a29c4d 100644
--- a/tasks.py
+++ b/tasks.py
@@ -26,6 +26,10 @@ def remove_check_file(path):
if os.path.isfile(path):
os.remove(path)
+def remove_dir(path):
+ if os.path.isdir(path):
+ shutil.rmtree(path)
+
def run_as(os_name):
if os_name.startswith('linux') or os_name == 'darwin' or os_name.startswith('freebsd'):
return 'sudo'
@@ -186,8 +190,8 @@ def begin(ctx):
ctx.run(cmd)
print ("** Done! Initialized the docker containers **")
-@task(begin)
-def deploy(ctx, fixtures=False):
+@task
+def deploy(ctx, fixtures=False, static=True):
run_as_cmd = run_as(OS_NAME)
print("** Setting up & migrating database **")
@@ -210,11 +214,20 @@ def deploy(ctx, fixtures=False):
ctx.run(cmd)
print("** Done! Loaded fixtures into database **")
- base_static_cmd = "docker exec -i yaksh_django python3 manage.py collectstatic"
- cmd = get_cmd(run_as_cmd, base_static_cmd)
- print ("** Setting up static assets **")
+ if static:
+ base_static_cmd = "docker exec -i yaksh_django python3 manage.py collectstatic"
+ cmd = get_cmd(run_as_cmd, base_static_cmd)
+ print ("** Setting up static assets **")
+ ctx.run(cmd)
+ print ("** Done! Set up static assets **")
+
+@task
+def status(ctx):
+ run_as_cmd = run_as(OS_NAME)
+ base_cmd = "docker-compose ps"
+ cmd = get_cmd(run_as_cmd, base_cmd)
+ print ("** Fetching container status **")
ctx.run(cmd)
- print ("** Done! Set up static assets **")
@task
def halt(ctx):
@@ -225,11 +238,22 @@ def halt(ctx):
ctx.run(cmd)
print ("** Done! Stopped containers **")
+@task
+def restart(ctx):
+ run_as_cmd = run_as(OS_NAME)
+ base_cmd = "docker-compose restart"
+ cmd = get_cmd(run_as_cmd, base_cmd)
+ print ("** Restarting containers **")
+ ctx.run(cmd)
+ print ("** Done! Restarted containers **")
+
@task(halt)
def remove(ctx):
run_as_cmd = run_as(OS_NAME)
base_cmd = "docker-compose rm --force"
cmd = get_cmd(run_as_cmd, base_cmd)
+ sql_dir = os.path.join(SCRIPT_DIR, 'docker', 'mysql')
print ("** Removing containers **")
+ remove_dir(sql_dir)
ctx.run(cmd)
print ("** Done! Removed containers **")