-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To keep things simple, this role currently deletes all apps on every run and starts the configured ones. This ensures, that no obsolete apps are running. New variables: * `pm2_cmds` run pm2 commands before managing apps * `pm2_cmds_default_env` default env to use for commands * `pm2_apps_default_env` default env to use for apps * `pm2_apps_default_cmd` default cmd to use for apps See README and tests/ for more details. closes #16
- Loading branch information
1 parent
e903eba
commit 0c51521
Showing
3 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
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,13 +1,20 @@ | ||
--- | ||
|
||
- name: Deleting all apps | ||
shell: pm2 delete all | ||
register: command_result | ||
failed_when: "'[ERROR]' in command_result.stderr" | ||
- name: Executing commands | ||
environment: "{{ item.env | default(pm2_cmds_default_env) }}" | ||
shell: "pm2 {{ item.run }} {{ item.args | default() }}" | ||
register: pm2_cmd_result | ||
args: | ||
chdir: "{{ item.path | default(omit) }}" | ||
failed_when: "item.ignore_errors|default(false) == false and ('[ERROR]' in pm2_cmd_result.stderr)" | ||
# ignore_errors: "item.ignore_errors|default(false)" this doesn't work!? | ||
with_items: "{{ pm2_cmds }}" | ||
|
||
- name: Starting apps | ||
environment: "{{ item.env | default({}) }}" | ||
shell: "pm2 start {{ item.run }} {{ item.args | default() }}" | ||
- name: Managing apps | ||
environment: "{{ item.env | default(pm2_apps_default_env) }}" | ||
shell: "pm2 {{ item.cmd | default(pm2_apps_default_cmd) }} {{ item.run }} {{ item.args | default() }}" | ||
register: pm2_app_result | ||
args: | ||
chdir: "{{ item.path | default(omit) }}" | ||
failed_when: "'[ERROR]' in pm2_app_result.stderr" | ||
with_items: "{{ pm2_apps }}" |
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