From b94b47a1443c57673bbbe7e65e25a4a6ac4689c4 Mon Sep 17 00:00:00 2001 From: keedya Date: Mon, 23 Nov 2015 20:25:02 +0000 Subject: [PATCH] Set post-install in package.json to cp upstart script to /etc/init npm start will launch shovel service --- Shovel/package.json | 4 ++++ Shovel/{ => scripts}/index.html | 0 Shovel/scripts/post-install.sh | 2 ++ Shovel/scripts/shovel.conf | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+) rename Shovel/{ => scripts}/index.html (100%) create mode 100755 Shovel/scripts/post-install.sh create mode 100755 Shovel/scripts/shovel.conf diff --git a/Shovel/package.json b/Shovel/package.json index c21f751..3447fcb 100644 --- a/Shovel/package.json +++ b/Shovel/package.json @@ -16,5 +16,9 @@ "devDependencies": { "should": "~7.0.1", "supertest": "~1.0.1" + }, + "scripts" :{ + "postinstall": "scripts/post-install.sh", + "start" : "start shovel" } } diff --git a/Shovel/index.html b/Shovel/scripts/index.html similarity index 100% rename from Shovel/index.html rename to Shovel/scripts/index.html diff --git a/Shovel/scripts/post-install.sh b/Shovel/scripts/post-install.sh new file mode 100755 index 0000000..02f5cd1 --- /dev/null +++ b/Shovel/scripts/post-install.sh @@ -0,0 +1,2 @@ +cp scripts/index.html node_modules/swagger-tools/middleware/swagger-ui/ +cp scripts/shovel.conf /etc/init/shovel.conf diff --git a/Shovel/scripts/shovel.conf b/Shovel/scripts/shovel.conf new file mode 100755 index 0000000..10f9998 --- /dev/null +++ b/Shovel/scripts/shovel.conf @@ -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