diff --git a/defaults/main.yml b/defaults/main.yml index f335f7c..c738422 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -9,9 +9,9 @@ nodejs_app_script: "src/index.js" nodejs_app_root_path: "{{ web_root }}/{{ nodejs_app_name }}" nodejs_app_static_path: "{{ web_root }}/{{ nodejs_app_name }}/static" -nodejs_app_nginx_hostname: localhost +nodejs_app_hostname: localhost -nodejs_app_supervisor_command: "PORT={{ nodejs_app_port }} node {{ nodejs_app_root }}/{{ nodejs_app_script }}" +nodejs_app_supervisor_command: "PORT={{ nodejs_app_port }} node {{ nodejs_app_root_path }}/{{ nodejs_app_script }}" nodejs_version_family: "5.x" # Other valid value is 4.x diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..ff9ee61 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,3 @@ +- name: restart nodejs app + supervisorctl: name={{ nodejs_app_service_name }} state=restarted config=/etc/supervisor/supervisord.conf + sudo: yes diff --git a/meta/main.yml b/meta/main.yml index 88029a6..bde4b3a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -18,19 +18,18 @@ galaxy_info: # # NOTE: A tag is limited to a single word comprised of # alphanumeric characters. Maximum 20 tags per role. - + # - role: "git+https://bitbucket.org/dorianpula/ansible-nodejs,,nodejs" + # - role: "git+https://bitbucket.org/dorianpula/ansible-nginx-uwsgi-supervisor,,nginx-uwsgi-supervisor" dependencies: - # - role: "git+https://bitbucket.org/dorianpula/ansible-nginx-uwsgi-supervisor,,nginx-uwsgi-supervisor" - - role: "nginx-supervisor" - nsbase_app_name: "{{ nodejs_app_name }}" - nsbase_app_root_path: "{{ nodejs_app_root_path }}" - nsbase_app_nginx_hostname: "{{ nodejs_app_nginx_hostname }}" - nsbase_app_service_name: "{{ nodejs_app_service_name }}" - nsbase_app_service_command: "{{ nodejs_app_supervisor_command }}" - nsbase_app_service_stop_signal: QUIT - nsbase_nginx_app_config: "{{ nodejs_app_nginx_config }}" - nsbase_app_nginx_static_path: "{{ nodejs_app_static_path }}" -# - role: "git+https://bitbucket.org/dorianpula/ansible-nodejs,,nodejs" - role: "nodejs" node_version_family: "{{ nodejs_version_family }}" - globally_installed_tools: nodejs_app_global_install + globally_installed_tools: "{{ nodejs_app_global_install }}" + - role: nginx-supervisor + nsbase_app_name: "{{ nodejs_app_name }}" + nsbase_app_root_path: "{{ nodejs_app_root_path }}" + nsbase_app_hostname: "{{ nodejs_app_hostname }}" + nsbase_app_service_name: "{{ nodejs_app_service_name }}" + nsbase_app_service_command: "{{ nodejs_app_supervisor_command }}" + nsbase_app_service_stop_signal: QUIT + nsbase_app_nginx_config: "{{ nodejs_app_nginx_config }}" + nsbase_app_static_path: "{{ nodejs_app_static_path }}" diff --git a/tasks/main.yml b/tasks/main.yml index f0bbe08..cfaff91 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,7 +6,7 @@ marker: "# -- {mark} NodeJS App config for {{ nodejs_app_name }} --" block: | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_pass 127.0.0.1:{{ nodejs_app_port }}; + proxy_set_header Host $http_host; + proxy_pass http://127.0.0.1:{{ nodejs_app_port }}; sudo: yes notify: restart nginx diff --git a/vars/main.yml b/vars/main.yml index 12e72df..9e041e6 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,4 +1,4 @@ --- # vars file for nodejs-nginx-supervisor -nodejs_app_nginx_config: "{{ app_name }}_nodejs_nginx.conf" -nodejs_app_service_name: "{{ app_name }}_nodejs" +nodejs_app_nginx_config: "{{ nodejs_app_name }}_nodejs_nginx.conf" +nodejs_app_service_name: "{{ nodejs_app_name }}_nodejs"