diff --git a/roles/blockscout/handlers/main.yml b/roles/blockscout/handlers/main.yml new file mode 100644 index 0000000..9a2e2d5 --- /dev/null +++ b/roles/blockscout/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart poa-blockscout + service: name=poa-blockscout state=restarted diff --git a/roles/blockscout/tasks/main.yml b/roles/blockscout/tasks/main.yml index 28b74ba..9b02e21 100644 --- a/roles/blockscout/tasks/main.yml +++ b/roles/blockscout/tasks/main.yml @@ -50,5 +50,10 @@ state: present become: true -- name: Start server - shell: cd {{ home }}/blockscout && mix phx.server +- name: Install poa-blockscout service + template: src=poa-blockscout.j2 dest=/etc/systemd/system/poa-blockscout.service owner={{ username }} group={{ username }} mode=0755 + notify: + - restart poa-blockscout + +- name: Ensure poa-blockscout is running and enabled to start at boot + service: name=poa-blockscout state=started enabled=yes diff --git a/roles/blockscout/templates/poa-blockscout.j2 b/roles/blockscout/templates/poa-blockscout.j2 new file mode 100644 index 0000000..81203bd --- /dev/null +++ b/roles/blockscout/templates/poa-blockscout.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=poa blockscout service +After=network.target +[Service] +User=root +Group=root +WorkingDirectory={{ home }}/blockscout +Restart=on-failure +RestartSec=5 +ExecStartPre=/usr/local/bin/mix local.hex --force +ExecStart=/usr/local/bin/mix phx.server +Type=simple +[Install] +WantedBy=multi-user.target