parse server: startup scripts, install the dashboard and configure it.

This commit is contained in:
Andrea Dell'Amico 2018-12-06 21:18:14 +01:00
parent c60dc3013f
commit ff1db9ac04
5 changed files with 69 additions and 1 deletions

View File

@ -7,5 +7,17 @@ parse_server_npm_modules:
parse_server_http_port: 1337
parse_server_db: parse_db
parse_server_mongodb_url: 'mongodb://localhost:27017/{{ parse_server_db }}'
parse_server_mongodb_uri: 'mongodb://localhost:27017/{{ parse_server_db }}'
parse_server_app_id: 'foo'
#parse_server_master_key: 'use a vault file'
parse_server_app_name: '{{ parse_server_app_id }}'
parse_server_dashboard_install: True
parse_server_dashboard_http_port: 4040
parse_dashboard_user: parse
#parse_dashboard_passwd: 'use a vault file'
# Encrypt the password with something like https://www.bcrypt-generator.com/
parse_dashboard_passwd_encrypted: 'true'
parse_server_dashboard_npm_modules:
- parse-dashboard

View File

@ -10,4 +10,31 @@
npm: name={{ item }} global=yes state=present production=true
with_items: '{{ parse_server_npm_modules }}'
- name: Install the parse server startup script
template: src=parse_server.upstart.j2 dest=/etc/init/parse_server.conf mode=0644
- name: Ensure that the parse service is started and enabled
service: name=parse_server state=started enabled=yes
tags: [ 'parse', 'parse_server' ]
- block:
- name: Install the parse server dashboard
npm: name={{ item }} global=yes state=present production=true
with_items: '{{ parse_server_dashboard_npm_modules }}'
- name: Install the parse dashboard environment variables file
template: src=parse-server-dashboard dest=/etc/default/parse-server-dashboard
- name: Install the parse dashboard configuration file
template: src=parse-dashboard-config.json dest={{ parse_server_user_home }}/parse-dashboard-config.json
- name: Install the parse dashboard startup script
template: src=parse_server_dashboard.upstart.j2 dest=/etc/init/parse_server_dashboard.conf mode=0644
- name: Ensure that the parse dashboard service is started and enabled
service: name=parse_server_dashboard state=started enabled=yes
when: parse_server_dashboard_install
tags: [ 'parse', 'parse_server', 'parse_server_dashboard' ]

View File

@ -0,0 +1,2 @@
export PARSE_DASHBOARD_TRUST_PROXY=1
export MOUNT_PATH=/dashboard

View File

@ -0,0 +1,12 @@
description "Parse server"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]
respawn
respawn limit 10 5
setuid {{ parse_server_user }}
setgid {{ parse_server_user }}
script
exec /usr/bin/parse-server --appId "{{ parse_server_app_id }}" --masterKey "{{ parse_server_master_key }}" --databaseURI {{ parse_server_mongodb_uri }}
end script

View File

@ -0,0 +1,15 @@
description "Parse server dashboard"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]
respawn
respawn limit 10 5
setuid {{ parse_server_user }}
setgid {{ parse_server_user }}
script
. /etc/default/parse-server-dashboard
export PARSE_DASHBOARD_TRUST_PROXY
export MOUNT_PATH
exec /usr/bin/parse-dashboard --config parse-dashboard-config.json
end script