-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
68 lines (43 loc) · 1.51 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
from fabric.api import run, abort, env, put, local, sudo
from fabric.decorators import runs_once
from fabric.context_managers import lcd, settings
from fabric.contrib.console import confirm
import os
war_file = "astrocats-0.1.0-SNAPSHOT-standalone.war"
def astrocats():
env.environment = "astrocats"
env.forward_agent = True
env.port = 22
env.hosts = ["162.213.39.149"]
env.user = "cloudsigma"
@runs_once
def _check():
if not confirm('deploy to %s?' % env.environment, default=False):
abort('deployment is cancelled.')
def _clean(path):
TARGETS = ['.DS_Store']
for root, dirs, files in os.walk(path):
for name in files:
if name in TARGETS:
os.remove(os.path.join(str(root), str(name)))
def deploy():
_check()
sudo(":")
local("rm -f resources/public/public.tar.gz")
local("lein clean")
local("lein cljsbuild clean")
local("lein cljsbuild once")
local("lein ring-jetty uberwar")
put("target/" + war_file, "/tmp/")
with lcd('resources/public'):
local("tar czf public.tar.gz *")
put("resources/public/public.tar.gz", "/tmp/")
run("rm -rf /var/www/astrocats/*")
run("tar xvf /tmp/public.tar.gz -C /var/www/astrocats")
with settings(sudo_user='jetty'):
sudo("cp -f /tmp/" + war_file +
" /usr/local/jetty/webapps/astrocats.war")
sudo("service jetty restart")
sudo("service nginx restart")
local("rm -f resources/public/public.tar.gz")