From 4f0dc6dde618e4f5c0c80ce1161aa7a83fdca3cf Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 28 Mar 2016 19:50:36 -0400 Subject: [PATCH] add upstart --- etc/init/walnut.conf | 21 +++++++++++++++++++++ install.sh | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 etc/init/walnut.conf create mode 100644 install.sh diff --git a/etc/init/walnut.conf b/etc/init/walnut.conf new file mode 100644 index 0000000..6b10255 --- /dev/null +++ b/etc/init/walnut.conf @@ -0,0 +1,21 @@ +description "WALNUT, by Daplie" +version "0.7" +author "Daplie Inc" + +# Upstart has nothing in $PATH by default +env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +# Keep the server running on crash or machine reboot +respawn +respawn limit 10 120 +start on runlevel [2345] + +# Start the server using spark and redirect output to log files +script + DATE=`date '+%F_%H-%M-%S'` + cd /srv/walnut + mkdir -p logs + exec node ./core/bin/walnut \ + > "./logs/access.${DATE}.log" \ + 2> "./logs/error.${DATE}.log" +end script diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c1f382f --- /dev/null +++ b/install.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +sudo mkdir -p /srv/walnut/{certs,core,lib} +sudo mkdir -p /srv/walnut/packages/{api,pages,services} +sudo chown -R $(whoami):$(whoami) /srv/walnut + +#git clone git@github.com:Daplie/walnut.git +git clone https://github.com/Daplie/walnut.git /srv/walnut/core + +pushd /srv/walnut/core +npm install +rsync -av /srv/walnut/core/etc/init/walnut.conf /etc/init/walnut.conf + +popd +mv /srv/walnut/core/node_modules /srv/walnut + +sudo service walnut stop +sudo service walnut start