add upstart script, setup instructions
This commit is contained in:
parent
fa0c3fa1b5
commit
3d53d03461
|
@ -1,3 +1,5 @@
|
|||
redirects.json
|
||||
vhosts
|
||||
.*.sw*
|
||||
|
||||
# Logs
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# secure the server with https://coolaj86.com/articles/securing-your-vps-for-the-semi-paranoid.html
|
||||
|
||||
# install walnut
|
||||
sudo mkdir /srv/walnut
|
||||
sudo chown walnut:walnut -R /srv/walnut
|
||||
pushd /srv/walnut
|
||||
git init
|
||||
git remote origin add git@github.com:daplie/walnut.git
|
||||
git pull
|
||||
npm install
|
||||
|
||||
# copy uid and guid to ./walnut.js
|
||||
id
|
||||
vim walnut.js
|
||||
|
||||
# configure redirects
|
||||
rsync -av redirects.sample.json redirects.json
|
||||
|
||||
# create and start upstart service
|
||||
sudo rsync -av upstart-walnut /etc/init/walnut.conf
|
||||
# for init.d: sudo rsync -av init.d-walnut /etc/init.d/walnut
|
||||
sudo service walnut restart
|
|
@ -0,0 +1,24 @@
|
|||
# sudo rsync -av upstart-walnut /etc/init/walnut.conf
|
||||
# sudo service walnut restart
|
||||
|
||||
description "WALNUT application host"
|
||||
version "1.0"
|
||||
author "AJ ONeal"
|
||||
|
||||
# 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 bin/walnut \
|
||||
> "./logs/access.${DATE}.log" \
|
||||
2> "./logs/error.${DATE}.log"
|
||||
end script
|
13
walnut.js
13
walnut.js
|
@ -73,7 +73,12 @@ function phoneHome() {
|
|||
console.error("Couldn't phone home. Oh well");
|
||||
});
|
||||
}
|
||||
require('./lib/insecure-server').create(securePort, insecurePort, redirects);
|
||||
require('./lib/vhost-sni-server.js').create(securePort, certsPath, vhostsdir)
|
||||
//.then(phoneHome)
|
||||
;
|
||||
|
||||
PromiseA.all(
|
||||
require('./lib/insecure-server').create(securePort, insecurePort, redirects)
|
||||
, require('./lib/vhost-sni-server.js').create(securePort, certsPath, vhostsdir)
|
||||
).then(function () {
|
||||
// TODO use `id' to find user's uid / gid and set to file
|
||||
process.setgid(1000);
|
||||
process.setuid(1000);
|
||||
})//.then(phoneHome);
|
||||
|
|
Loading…
Reference in New Issue