Skip to content

Commit

Permalink
feat: add pm2 post commands
Browse files Browse the repository at this point in the history
Merge branch 'feature/pm2_save' of https://github.com/pritha-intelliB/ansible-pm2 into feature/pm2_save

closes #22
  • Loading branch information
franklinkim committed Sep 26, 2017
2 parents c396e9f + b802949 commit 05d6149
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ pm2_service_state: started
pm2_version:
# user to run pm2 commands
pm2_user: "{{ ansible_user_id }}"
# default post command to run on apps
pm2_apps_post_cmd: []
pm2_apps_save: save
11 changes: 11 additions & 0 deletions tasks/manage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@
chdir: "{{ item.path | default(omit) }}"
failed_when: "pm2_app_result.stderr is defined and pm2_app_result.stderr.find('[ERROR]') != -1"
with_items: "{{ pm2_apps }}"

- name: Saving the state of the apps
become_user: "{{ pm2_user }}"
become: yes
environment: "{{ item.env | default(pm2_apps_default_env) }}"
shell: "pm2 {{ item.cmd | default(pm2_apps_save) }} "
register: pm2_app_save_result
args:
chdir: "{{ item.path | default(omit) }}"
failed_when: "pm2_app_result.stderr is defined and pm2_app_result.stderr.find('[ERROR]') != -1"
with_items: "{{ pm2_apps_post_cmd }}"

0 comments on commit 05d6149

Please sign in to comment.