From 9f540774b1fa2d9035a8b19dd1901247b112ead5 Mon Sep 17 00:00:00 2001
From: Chocobozzz <florian.bigard@gmail.com>
Date: Fri, 21 Oct 2016 14:23:20 +0200
Subject: [PATCH] Add upgrade script

---
 package.json       |  1 +
 scripts/help.sh    |  1 +
 scripts/upgrade.sh | 16 ++++++++++++++++
 server.js          |  2 ++
 4 files changed, 20 insertions(+)
 create mode 100755 scripts/upgrade.sh

diff --git a/package.json b/package.json
index 8e2163bb2f..93c748cd32 100644
--- a/package.json
+++ b/package.json
@@ -31,6 +31,7 @@
     "dev": "scripty",
     "start": "node server",
     "check": "scripty",
+    "upgrade": "scripty",
     "test": "scripty",
     "help": "scripty",
     "postinstall": "cd client && npm install"
diff --git a/scripts/help.sh b/scripts/help.sh
index fdccabbf01..23c460afa4 100755
--- a/scripts/help.sh
+++ b/scripts/help.sh
@@ -16,5 +16,6 @@ printf "  play                 -> Run 3 fresh nodes so that you can test the com
 printf "  dev                  -> Watch, run the livereload and run the server so that you can develop the application\n"
 printf "  start                -> Run the server\n"
 printf "  check                -> Check the server (according to NODE_ENV)\n"
+printf "  upgrade -- [branch]  -> Upgrade the application according to the [branch] parameter\n"
 printf "  test                 -> Run the tests\n"
 printf "  help                 -> Print this help\n"
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh
new file mode 100755
index 0000000000..1299ac55a0
--- /dev/null
+++ b/scripts/upgrade.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env sh
+
+
+git pull origin $(git rev-parse --abbrev-ref HEAD) || exit -1
+
+if [[ `pgrep peertube` > /dev/null ]]; then
+  echo 'PeerTube is running!'
+  exit 0
+fi
+
+npm install
+npm update
+cd client && npm update && cd ../
+npm run build
+
+echo "\n\nUpgrade finished! You can restart PeerTube that may run the migration scripts."
diff --git a/server.js b/server.js
index d540c301b5..d866f628c1 100644
--- a/server.js
+++ b/server.js
@@ -11,6 +11,8 @@ const path = require('path')
 const TrackerServer = require('bittorrent-tracker').Server
 const WebSocketServer = require('ws').Server
 
+process.title = 'peertube'
+
 // Create our main app
 const app = express()
 
-- 
GitLab