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: yes
become_user: codimd 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 # Connection to database
- name: Connect CodiMD to PostgreSQL db - name: Connect CodiMD to PostgreSQL db
template: template:
src: sequelizerc src: sequelizerc.j2
dest: /var/local/codimd/codimd/.sequelizerc dest: /var/local/codimd/codimd/.sequelizerc
owner: codimd owner: codimd
group: codimd group: codimd
@ -41,9 +41,29 @@
become: yes become: yes
become_user: codimd become_user: codimd
# Config CodiMD # Configure
# config.json template - name: Configure CodiMD
template:
src: config.json.j2
dest: /var/local/codimd/codimd/config.json
owner: codimd
group: codimd
mode: 0600
# Config SystemD service # Service file
# NODE_ENV="production" npm start - 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