diff --git a/dockerfile b/dockerfile index 0388d4bc..923d8b10 100644 --- a/dockerfile +++ b/dockerfile @@ -31,6 +31,7 @@ RUN npm run build EXPOSE 3001 VOLUME ["/app/data"] +HEALTHCHECK --interval=5s --timeout=3s --start-period=30s CMD node extra/healthcheck.js CMD ["npm", "run", "start-server"] FROM release AS nightly diff --git a/extra/healthcheck.js b/extra/healthcheck.js new file mode 100644 index 00000000..b547fbcb --- /dev/null +++ b/extra/healthcheck.js @@ -0,0 +1,19 @@ +var http = require("http"); +var options = { + host: "localhost", + port: "3001", + timeout: 2000, +}; +var request = http.request(options, (res) => { + console.log(`STATUS: ${res.statusCode}`); + if (res.statusCode == 200) { + process.exit(0); + } else { + process.exit(1); + } +}); +request.on("error", function (err) { + console.log("ERROR"); + process.exit(1); +}); +request.end(); diff --git a/index.html b/index.html index 3dd55d3f..66d58c1e 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,8 @@ + + Uptime Kuma diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png index db02af7b..3bb82e4c 100644 Binary files a/public/apple-touch-icon.png and b/public/apple-touch-icon.png differ diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 00000000..e9e57dc4 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/server/notification.js b/server/notification.js index 99cc1568..e264f716 100644 --- a/server/notification.js +++ b/server/notification.js @@ -15,7 +15,7 @@ class Notification { }) return true; } catch (error) { - console.log(error) + console.error(error) return false; } @@ -31,7 +31,7 @@ class Notification { }) return true; } catch (error) { - console.log(error) + console.error(error) return false; } @@ -61,7 +61,7 @@ class Notification { let res = await axios.post(notification.webhookURL, finalData, config) return true; } catch (error) { - console.log(error) + console.error(error) return false; } @@ -105,7 +105,7 @@ class Notification { let res = await axios.post(notification.discordWebhookUrl, data) return true; } catch(error) { - console.log(error) + console.error(error) return false; } @@ -121,20 +121,24 @@ class Notification { let res = await axios.post(notification.signalURL, data, config) return true; } catch (error) { - console.log(error) + console.error(error) return false; } - + } else if (notification.type === "slack") { try { if (heartbeatJSON == null) { - let data = {'text': "Uptime Kuma Slack testing successful."} + let data = {'text': "Uptime Kuma Slack testing successful.", 'channel': notification.slackchannel, 'username': notification.slackusername, 'icon_emoji': notification.slackiconemo} let res = await axios.post(notification.slackwebhookURL, data) return true; } const time = heartbeatJSON["time"]; let data = { + "text": "Uptime Kuma Alert", + "channel":notification.slackchannel, + "username": notification.slackusername, + "icon_emoji": notification.slackiconemo, "blocks": [{ "type": "header", "text": { @@ -155,23 +159,52 @@ class Notification { ] }, { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { "type": "plain_text", "text": "Visit Uptime Kuma", }, - "value": "Uptime-Kuma", - "url": notification.slackbutton - } + "value": "Uptime-Kuma", + "url": notification.slackbutton || "https://github.com/louislam/uptime-kuma" + } ] } ] } let res = await axios.post(notification.slackwebhookURL, data) return true; + } catch (error) { + console.error(error) + return false; + } + + } else if (notification.type === "pushover") { + var pushoverlink = 'https://api.pushover.net/1/messages.json' + try { + if (heartbeatJSON == null) { + let data = {'message': "Uptime Kuma Pushover testing successful.", + 'user': notification.pushoveruserkey, 'token': notification.pushoverapptoken, 'sound':notification.pushoversounds, + 'priority': notification.pushoverpriority, 'title':notification.pushovertitle, 'retry': "30", 'expire':"3600", 'html': 1} + let res = await axios.post(pushoverlink, data) + return true; + } + + let data = { + "message": "Uptime Kuma Alert\n\nMessage:" +msg + '\nTime (UTC):' +time, + "user":notification.pushoveruserkey, + "token": notification.pushoverapptoken, + "sound": notification.pushoversounds, + "priority": notification.pushoverpriority, + "title": notification.pushovertitle, + "retry": "30", + "expire": "3600", + "html": 1 + } + let res = await axios.post(pushoverlink, data) + return true; } catch (error) { console.log(error) return false; diff --git a/server/server.js b/server/server.js index 93e43cd6..b53f32b4 100644 --- a/server/server.js +++ b/server/server.js @@ -19,7 +19,7 @@ const version = require('../package.json').version; const hostname = args.host || "0.0.0.0" const port = args.port || 3001 -console.log("Version: " + version) +console.info("Version: " + version) console.log("Creating express and socket.io instance") const app = express(); @@ -236,7 +236,7 @@ let needSetup = false; }); } catch (e) { - console.log(e) + console.error(e) callback({ ok: false, msg: e.message diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 15991517..c5be0c65 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -20,6 +20,7 @@ + @@ -191,15 +192,80 @@ + + diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index b9aca97f..85109e12 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -9,7 +9,7 @@
- + Uptime Kuma @@ -37,7 +37,7 @@
Uptime Kuma - Version: {{ $root.info.version }} - - Check Update On GitHub + Check Update On GitHub
@@ -146,6 +146,7 @@ footer { font-size: 13px; margin-bottom: 30px; margin-left: 10px; + text-align: center; } diff --git a/src/util-frontend.js b/src/util-frontend.js index 7094c159..abdf7b5a 100644 --- a/src/util-frontend.js +++ b/src/util-frontend.js @@ -394,7 +394,7 @@ export function timezoneList() { time: getTimezoneOffset(timezone), }) } catch (e) { - console.log(e.message); + console.error(e.message); console.log("Skip this timezone") }