diff --git a/Ansible/roles/meshmage/files/meshmage-worker.service b/Ansible/roles/meshmage/files/meshmage-worker.service new file mode 100644 index 0000000..689a2a7 --- /dev/null +++ b/Ansible/roles/meshmage/files/meshmage-worker.service @@ -0,0 +1,17 @@ +[Unit] +Description=MeshMage Worker Service +After=network.target + +[Service] +ExecStart=/home/meshmage/perl5/bin/plx ./script/meshmage_web minion worker +Restart=on-failure +User=meshmage +Group=meshmage +WorkingDirectory=/home/meshmage/MeshMage/Web +Environment="PERL_MB_OPT=--install_base \"/home/meshmage/perl5\"" +Environment="PERL_MM_OPT=INSTALL_BASE=/home/meshmage/perl5" +Environment="PERL5LIB=/home/meshmage/perl5/lib/perl5" +Environment="PATH=/home/meshmage/perl5/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" + +[Install] +WantedBy=multi-user.target diff --git a/Ansible/roles/meshmage/files/meshmage.service b/Ansible/roles/meshmage/files/meshmage.service new file mode 100644 index 0000000..8566ef4 --- /dev/null +++ b/Ansible/roles/meshmage/files/meshmage.service @@ -0,0 +1,17 @@ +[Unit] +Description=MeshMage Web Service +After=network.target + +[Service] +ExecStart=/home/meshmage/perl5/bin/plx ./script/meshmage_web daemon +Restart=on-failure +User=meshmage +Group=meshmage +WorkingDirectory=/home/meshmage/MeshMage/Web +Environment="PERL_MB_OPT=--install_base \"/home/meshmage/perl5\"" +Environment="PERL_MM_OPT=INSTALL_BASE=/home/meshmage/perl5" +Environment="PERL5LIB=/home/meshmage/perl5/lib/perl5" +Environment="PATH=/home/meshmage/perl5/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" + +[Install] +WantedBy=multi-user.target diff --git a/Ansible/roles/meshmage/tasks/main.yml b/Ansible/roles/meshmage/tasks/main.yml index f57e1ae..1079db0 100644 --- a/Ansible/roles/meshmage/tasks/main.yml +++ b/Ansible/roles/meshmage/tasks/main.yml @@ -228,6 +228,30 @@ become: true become_user: meshmage -# Setup services files for meshmage +- name: Install meshmage.service file. + copy: + dest: /etc/systemd/system/meshmage.service + src: "{{ role_path }}/files/meshmage.service" + owner: root + group: root + mode: 0644 -# Enable services for meshmage web / worker +- name: Install meshmage-worker.service file. + copy: + dest: /etc/systemd/system/meshmage-worker.service + src: "{{ role_path }}/files/meshmage-worker.service" + owner: root + group: root + mode: 0644 + +- name: Start MeshMage + service: + name: meshmage + state: started + enabled: true + +- name: Start MeshMage-Worker + service: + name: meshmage-worker + state: started + enabled: true