TECHIES WORLD

For Techs.... Techniques.... Technologies....

AWSLinux

How to use forever in Ansible

Forever is the module that used to run nodejs applications as a daemon.

This article explains the configurations to start and stop forever processes using Ansible.

Sample playbook to start the forever process is given below.

- name: Start App
  command: forever start app.js
  args:
    chdir: "app-folder"

Where app-folder need to be replaced with the exact folder in which the application located.

Sample playbook to stop all the forever process is given below.

- name: Stop App
  command: forever stopall
  ignore_errors: yes
  args:
    chdir: "app-folder"

Where app-folder need to be replaced with the exact folder in which the application located.

Please note that one additional parameter "ignore_errors: yes" included to avoid error on stoping forever if the process not exists.

That's all…

Leave a Reply