Added SystemD services for Kustvakt and Kalamar (thx Peter)
Change-Id: I9081d2b5990cde2bf5e1337f279e940b039e98fd
diff --git a/Vagrantfile b/Vagrantfile
index 33f2ce3..24989bd 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -8,7 +8,7 @@
# https://docs.vagrantup.com.
# More at https://vagrantcloud.com/search.
- config.vm.box = "ubuntu/trusty64"
+ config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
@@ -113,7 +113,6 @@
source ~/perl5/perlbrew/etc/bashrc
- perlbrew self-upgrade
perlbrew install -q perl-5.24.0
perlbrew switch perl-5.24.0
@@ -195,5 +194,42 @@
MOJO_MODE=vagrant \
hypnotoad script/kalamar
+
+ ###############################################
+ echo "Establish systemd"
+
+ echo "[Unit]
+Description=Kustvakt
+After=network.target
+
+[Service]
+User=root
+Type=forking
+ExecStart=/bin/su - vagrant -c 'cd /home/vagrant/Built ; nohup java -jar Kustvakt-lite.jar & echo $! > kustvakt.pid'
+PIDFile=/home/vagrant/Built/kustvakt.pid
+KillMode=process
+
+[Install]
+WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kustvakt.service
+
+ echo "[Unit]
+Description=Kalamar
+After=network.target
+
+[Service]
+User=root
+Type=forking
+PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid
+ExecStart=/bin/su - vagrant -c 'MOJO_MODE=vagrant KALAMAR_API=\"http://localhost:5556/api/\" /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad /home/vagrant/Kalamar/script/kalamar'
+ExecStop=/bin/su - vagrant -c 'MOJO_MODE=vagrant /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad -s /home/vagrant/Kalamar/script/kalamar'
+ExecReload=/bin/su - vagrant -c 'MOJO_MODE=vagrant KALAMAR_API=\"http://localhost:5556/api/\" /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad /home/vagrant/Kalamar/script/kalamar'
+killMode=process
+
+[Install]
+WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service
+
+ sudo systemctl enable kustvakt
+ sudo systemctl enable kalamar
+
SHELL
end