Set post-install in package.json to cp upstart script to /etc/init

npm start will launch shovel service
This commit is contained in:
keedya 2015-11-23 20:25:02 +00:00
parent 469dc2a524
commit b94b47a144
4 changed files with 28 additions and 0 deletions

View File

@ -16,5 +16,9 @@
"devDependencies": {
"should": "~7.0.1",
"supertest": "~1.0.1"
},
"scripts" :{
"postinstall": "scripts/post-install.sh",
"start" : "start shovel"
}
}

2
Shovel/scripts/post-install.sh Executable file
View File

@ -0,0 +1,2 @@
cp scripts/index.html node_modules/swagger-tools/middleware/swagger-ui/
cp scripts/shovel.conf /etc/init/shovel.conf

22
Shovel/scripts/shovel.conf Executable file
View File

@ -0,0 +1,22 @@
#!upstart
description "start shovel server"
start on startup
stop on shutdown
script
export HOME="/root"
echo $$ > /var/run/shovel.pid
echo Starting shovel service
chdir /var/Shovel/
exec /usr/bin/nodejs main.js >> /var/log/shovel.log 2>&1
end script
pre-start script
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/shovel.log
end script
pre-stop script
rm /var/run/shovel.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/shovel.log
end script