-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.yml
63 lines (52 loc) · 1.57 KB
/
main.yml
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
---
- name: ensure {{ deploy_dir }} exists
sudo: yes
file: name={{ item }} state=directory owner=root group=root
with_items:
- $deploy_dir
- $deploy_app_dir
- name: clone
sudo: yes
git: repo={{ repo_url }} dest={{ deploy_app_dir }}
- name: install meteor dependencies
sudo: yes
shell: chdir={{ deploy_app_dir }} mrt install
- name: remove current running app
sudo: yes
shell: chdir={{ deploy_app_dir }} rm -rf bundle
- name: bundle app
sudo: yes
shell: chdir={{ deploy_app_dir }} meteor bundle bundle.tgz
- name: unbundle app
sudo: yes
shell: chdir={{ deploy_app_dir }} tar -xzvf bundle.tgz
- name: register the current pids
sudo: yes
shell: ps aux | grep {{ pid_expression }} | grep -v grep | awk '{print $2}'
register: pids
- name: start app with forever
sudo: yes
shell: >
PORT={{ port }}
MONGO_URL={{ mongo_url }}
forever start "{{ deploy_app_dir }}"/bundle/main.js
async: 10
poll: 1
- name: copy nginx virtual host file
sudo: yes
template: src="{{app_name}}.j2"
dest="/etc/nginx/sites-available/{{app_name}}"
owner=root
group=root
- name: link nginx virtual host file
sudo: yes
file: src="/etc/nginx/sites-available/{{app_name}}"
dest="/etc/nginx/sites-enabled/{{app_name}}"
state=link
- name: restart nginx
sudo: yes
service: name=nginx state=restarted
- name: kill the old pids
sudo: yes
shell: kill -9 {{ item }}
with_items: pids.stdout_lines