This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ability to control go client, closes #30
- Loading branch information
sveneh
committed
Feb 12, 2015
1 parent
b746a3e
commit 43279f3
Showing
9 changed files
with
155 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
# this is just for testing. | ||
- name: Ansible-only testing scenario | ||
hosts: tag_Name_client-01 | ||
# hosts: tag_Role_client | ||
remote_user: ubuntu | ||
gather_facts: false | ||
roles: | ||
- clients | ||
|
||
tasks: | ||
- include: roles/clients/tasks/start.yml | ||
vars: | ||
|
||
# these are normally set from the python controller | ||
dbg_req_num_peers: 3 | ||
dbg_mining_cpu_percentage: 10 | ||
|
||
docker_container_id: | ||
go: container_go | ||
python: container_python | ||
|
||
docker_run_args: | ||
go: -loglevel=5 -seednode={{ groups['tag_Name_boot'][0] }}:30303 -maxpeer={{ dbg_req_num_peers }} | ||
python: --logging :debug --log_json 1 --remote {{ groups['tag_Name_boot'][0] }} --port 30303 --mining {{ dbg_mining_cpu_percentage }} --peers {{ dbg_req_num_peers }} | ||
|
||
docker_tee_args: | ||
go: "{{ groups['tag_Name_elarch'][0]}}" | ||
python: "{{ groups['tag_Name_elarch'][0]}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
# this is just for testing. | ||
- name: Ansible-only testing scenario | ||
hosts: tag_Name_client-01 | ||
# hosts: tag_Role_client | ||
remote_user: ubuntu | ||
gather_facts: false | ||
roles: | ||
- clients | ||
|
||
tasks: | ||
- include: roles/clients/tasks/stop.yml | ||
vars: | ||
|
||
# these are normally set from the python controller | ||
docker_container_id: | ||
go: container_go | ||
python: container_python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,51 @@ | ||
--- | ||
# this will only work when missing parameters are injected into the inventory file. | ||
- name: start client with parameters from inventory file | ||
# TODO: run all clients in a loop | ||
|
||
- name: start go client with parameters from inventory file | ||
docker: | ||
image: "{{ docker_image['go'] }}" | ||
name: "{{ docker_container_id['go'] }}" | ||
expose: ["8080", "30303"] | ||
ports: ["20000:30203", "30000:30303"] | ||
command: "{{ docker_run_args['go'] }}" | ||
tags: | ||
- go | ||
|
||
- name: start python client with parameters from inventory file | ||
docker: | ||
image: "{{ docker_image['python'] }}" | ||
name: "{{ docker_container_id['python'] }}" | ||
expose: ["30203", "30303"] | ||
ports: ["22000:30203", "32000:30303"] | ||
command: "{{ docker_run_args['python'] }}" | ||
tags: | ||
- python | ||
|
||
- name: Forward logfiles with parameters from inventory file | ||
- name: Forward go logfiles with parameters from inventory file | ||
# fire and forget, don't wait to finish, run for one day | ||
async: 86400 | ||
poll: 0 | ||
# again, ansible docker module does not support logs | ||
shell: docker logs --follow=true {{ docker_container_id['go'] }} 2>&1 | {{ repo_path }}/logging/teees.py {{ docker_tee_args['go'] }} | ||
register: log_runner_go | ||
tags: | ||
- go | ||
|
||
- name: verify previous task | ||
async_status: jid={{ log_runner_go.ansible_job_id }} | ||
tags: | ||
- go | ||
|
||
- name: Forward python logfiles with parameters from inventory file | ||
async: 86400 | ||
poll: 0 | ||
shell: docker logs --follow=true {{ docker_container_id['python'] }} 2>&1 | {{ repo_path }}/logging/teees.py {{ docker_tee_args['python'] }} | ||
register: log_runner | ||
register: log_runner_python | ||
tags: | ||
- python | ||
|
||
- name: verify previous task | ||
async_status: jid={{ log_runner.ansible_job_id }} | ||
async_status: jid={{ log_runner_python.ansible_job_id }} | ||
tags: | ||
- python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
--- | ||
# this will only work when missing parameters are injected into the inventory file. | ||
- name: Stop client docker instances | ||
# TODO do all in a loop | ||
|
||
- name: Stop go client docker instances | ||
# ansible docker does not support stop by container name, only by image name. Stupid. | ||
shell: docker stop {{ docker_container_id['go'] }} | ||
tags: | ||
- go | ||
|
||
- name: Persist state of stopped go client | ||
# ansible docker module does not support this ... | ||
shell: docker commit {{ docker_container_id['go'] }} {{ docker_image['go'] }} | ||
tags: | ||
- go | ||
|
||
- name: Stop go docker log forwarding | ||
# there is no Ansible API to stop async tasks, unfortunately. | ||
shell: pkill --parent $(pgrep --full "docker logs.*{{ docker_container_id['go'] }}.*teees") | ||
# pkill gives -15 return code, don't know why. Ignore it | ||
failed_when: false | ||
tags: | ||
- go | ||
|
||
- name: Stop python client docker instances | ||
# ansible docker does not support stop by container name, only by image name. Stupid. | ||
shell: docker stop {{ docker_container_id['python'] }} | ||
tags: | ||
- python | ||
|
||
- name: Persist state of stopped client | ||
- name: Persist state of stopped python client | ||
# ansible docker module does not support this ... | ||
shell: docker commit {{ docker_container_id['python'] }} {{ docker_image['python'] }} | ||
tags: | ||
- python | ||
|
||
|
||
- name: Stop docker log forwarding | ||
- name: Stop python docker log forwarding | ||
# there is no Ansible API to stop async tasks, unfortunately. | ||
shell: "{{ item }}" | ||
with_items: | ||
- pkill --full teees | ||
- pkill --full "docker logs" | ||
shell: pkill --parent $(pgrep --full "docker logs.*{{ docker_container_id['python'] }}.*teees") | ||
# pkill gives -15 return code, don't know why. Ignore it | ||
failed_when: false | ||
tags: | ||
- python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters