Add systemd unit

This commit is contained in:
Alexandre Iooss 2019-02-09 10:02:53 +01:00
parent 5f194f0e30
commit 19c2eca917
5 changed files with 87 additions and 5 deletions

View File

@ -7,3 +7,7 @@
become: yes
become_user: codimd
# Reload systemd daemons when a service file changes
- name: Reload systemd daemons
command: systemctl daemon-reload

View File

@ -27,7 +27,7 @@
# Connection to database
- name: Connect CodiMD to PostgreSQL db
template:
src: sequelizerc
src: sequelizerc.j2
dest: /var/local/codimd/codimd/.sequelizerc
owner: codimd
group: codimd
@ -41,9 +41,29 @@
become: yes
become_user: codimd
# Config CodiMD
# config.json template
# Configure
- name: Configure CodiMD
template:
src: config.json.j2
dest: /var/local/codimd/codimd/config.json
owner: codimd
group: codimd
mode: 0600
# Config SystemD service
# NODE_ENV="production" npm start
# Service file
- name: Install CodiMD systemd unit
template:
src: 'systemd/codimd.service.j2'
dest: '/etc/systemd/system/codimd.service'
owner: root
group: root
mode: 0644
notify: Reload systemd daemons
# Run
- name: Ensure that CodiMD is started
service:
name: codimd
state: started
enabled: true

View File

@ -0,0 +1,38 @@
{
"production": {
"domain": "codimd.auro.re",
"debug": false,
"port": 8080,
"useSSL": false,
"protocolUseSSL": true,
"useCDN": false,
"csp": {
"enable": true,
"directives": {
},
"upgradeInsecureRequests": "auto",
"addDefaults": true
},
"db": {
"username": "codimd",
"password": "{{ postgresql_codimd_passwd }}",
"database": "codimd",
"host": "{{ postgresql_services_url }}",
"port": "5432",
"dialect": "postgres"
},
"email": false,
"ldap": {
"url": "{{ ldap_master_uri }}",
"bindDn": null,
"bindCredentials": null,
"searchBase": "change this",
"searchFilter": "change this",
"searchAttributes": ["change this"],
"usernameField": "change this e.g. cn",
"useridField": "change this e.g. uid"
},
"allowFreeURL": true
}
}

View File

@ -0,0 +1,20 @@
# /etc/systemd/system/codimd.service
# Deployed with Aurore Ansible !
[Unit]
Description=CodiMD
After=syslog.target network-online.target mysql.service postgresql.service
Conflicts=shutdown.target
[Service]
Type=simple
User=codimd
Group=codimd
WorkingDirectory=/var/local/codimd/codimd
Environment="NODE_ENV=production"
ExecStart=/usr/bin/nodejs /var/local/codimd/codimd/app.js
Restart=always
[Install]
WantedBy=multi-user.target