From 577f7313574e6263a58d8ab070b78bda92388e2e Mon Sep 17 00:00:00 2001 From: Pete Maynard Date: Tue, 13 Dec 2016 12:03:47 +0000 Subject: [PATCH] Adds systemD to monitor proccess --- roles/synapse/tasks/main.yml | 22 +++++++++++++++------- roles/synapse/templates/synapse.service | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 roles/synapse/templates/synapse.service diff --git a/roles/synapse/tasks/main.yml b/roles/synapse/tasks/main.yml index 5f35685..f6d1b49 100644 --- a/roles/synapse/tasks/main.yml +++ b/roles/synapse/tasks/main.yml @@ -40,16 +40,24 @@ # TODO: Deploy the config template using vault to store the secrets. # - Port 8448 listen should be bound to localhost # - x_forwarded: true - # TODO: Systemd service for synapse - - - name: Start synapse - command: bin/synctl start - args: - chdir: ~/.synapse - + + # - name: Create directories needed + # file: + # path: ~/.config/systemd/user/ + # state: directory + # mode: 0755 become: yes become_user: synapse +- name: SystemD Service + template: src=synapse.service dest=/etc/systemd/system/synapse.service + +- name: Enabling Service + command: systemctl enable synapse.service + +- name: Start synapse + command: service synapse start + - name: Enable nginx reverse proxy blockinfile: dest: /etc/nginx/sites-available/matrix.ac diff --git a/roles/synapse/templates/synapse.service b/roles/synapse/templates/synapse.service new file mode 100644 index 0000000..ae58813 --- /dev/null +++ b/roles/synapse/templates/synapse.service @@ -0,0 +1,14 @@ +[Unit] +Description=Synapse Matrix Homeserver + +[Service] +Type=forking +PIDFile=/home/synapse/.synapse/homeserver.pid +User=synapse +Group=synapse +Restart=on-failure +WorkingDirectory=/home/synapse/.synapse/ +ExecStart=/home/synapse/.synapse/bin/synctl start + +[Install] +WantedBy=multi-user.target \ No newline at end of file