diff --git a/gitGraph.service b/gitGraph.service new file mode 100644 index 0000000..ad86ec6 --- /dev/null +++ b/gitGraph.service @@ -0,0 +1,21 @@ +# File Location /lib/systemd/system +# +# After file creation run: systemctl daemon-reload +# enable service on start up: systemctl enable jeff +# start the service: systemctl start jrtechs + + +[Unit] +Description=Node app for github app +Documentation=https://jrtechs.net +After=network.target + +[Service] +Type=simple +User=jeff +WorkingDirectory=/var/www/github-graphs.com/github-graphs +ExecStart=/var/www/github-graphs.com/github-graphs/run.sh +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/routes/api.js b/routes/api.js index 0c0befb..1f420de 100644 --- a/routes/api.js +++ b/routes/api.js @@ -66,6 +66,10 @@ routes.get('/*', (request, result) => { result.write(JSON.stringify(data)); } + else + { + result.write("[]"); + } result.end(); }).catch(function(error) { @@ -75,8 +79,15 @@ routes.get('/*', (request, result) => { result.write(JSON.stringify(error)); } + else + { + result.write("[]"); + } + } - catch(error) {}; + catch(error) { + result.write("[]"); + }; result.end(); }); diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..bf2733a --- /dev/null +++ b/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# run - this script enters a infinite loop to ensure that the website does not go down if it +# hits any unexpected error that crashes Nodejs +# +# 2/13/18 Jeffery Russell + +while true +do node server.js +done \ No newline at end of file