Browse Source
# Conflicts: # README.md # dockerfile # package-lock.json # package.json # server/notification.js # server/server.js # src/assets/vars.scss # src/components/NotificationDialog.vue # src/layouts/Layout.vue # src/mixins/socket.js # src/pages/Dashboard.vue # src/pages/EditMonitor.vuepull/154/head^2
35 changed files with 1058 additions and 485 deletions
@ -0,0 +1,10 @@ |
|||||
|
--- |
||||
|
name: ⚠ Please go to "Discussions" Tab if you want to ask or share something |
||||
|
about: BUG REPORT ONLY HERE |
||||
|
title: '' |
||||
|
labels: '' |
||||
|
assignees: '' |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
BUG REPORT ONLY HERE |
@ -0,0 +1,34 @@ |
|||||
|
--- |
||||
|
name: Bug report |
||||
|
about: Create a report to help us improve |
||||
|
title: '' |
||||
|
labels: bug |
||||
|
assignees: '' |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
**Describe the bug** |
||||
|
A clear and concise description of what the bug is. |
||||
|
|
||||
|
**To Reproduce** |
||||
|
Steps to reproduce the behavior: |
||||
|
1. Go to '...' |
||||
|
2. Click on '....' |
||||
|
3. Scroll down to '....' |
||||
|
4. See error |
||||
|
|
||||
|
**Expected behavior** |
||||
|
A clear and concise description of what you expected to happen. |
||||
|
|
||||
|
**Screenshots** |
||||
|
If applicable, add screenshots to help explain your problem. |
||||
|
|
||||
|
**Desktop (please complete the following information):** |
||||
|
- Uptime Kuma Version: |
||||
|
- Using Docker?: Yes/No |
||||
|
- OS: |
||||
|
- Browser: |
||||
|
|
||||
|
|
||||
|
**Additional context** |
||||
|
Add any other context about the problem here. |
Binary file not shown.
@ -0,0 +1,37 @@ |
|||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. |
||||
|
-- Change Monitor.created_date from "TIMESTAMP" to "DATETIME" |
||||
|
-- SQL Generated by Intellij Idea |
||||
|
PRAGMA foreign_keys=off; |
||||
|
|
||||
|
BEGIN TRANSACTION; |
||||
|
|
||||
|
create table monitor_dg_tmp |
||||
|
( |
||||
|
id INTEGER not null |
||||
|
primary key autoincrement, |
||||
|
name VARCHAR(150), |
||||
|
active BOOLEAN default 1 not null, |
||||
|
user_id INTEGER |
||||
|
references user |
||||
|
on update cascade on delete set null, |
||||
|
interval INTEGER default 20 not null, |
||||
|
url TEXT, |
||||
|
type VARCHAR(20), |
||||
|
weight INTEGER default 2000, |
||||
|
hostname VARCHAR(255), |
||||
|
port INTEGER, |
||||
|
created_date DATETIME, |
||||
|
keyword VARCHAR(255) |
||||
|
); |
||||
|
|
||||
|
insert into monitor_dg_tmp(id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword) select id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword from monitor; |
||||
|
|
||||
|
drop table monitor; |
||||
|
|
||||
|
alter table monitor_dg_tmp rename to monitor; |
||||
|
|
||||
|
create index user_id on monitor (user_id); |
||||
|
|
||||
|
COMMIT; |
||||
|
|
||||
|
PRAGMA foreign_keys=on; |
@ -0,0 +1,37 @@ |
|||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. |
||||
|
-- Add maxretries column to monitor |
||||
|
PRAGMA foreign_keys=off; |
||||
|
|
||||
|
BEGIN TRANSACTION; |
||||
|
|
||||
|
create table monitor_dg_tmp |
||||
|
( |
||||
|
id INTEGER not null |
||||
|
primary key autoincrement, |
||||
|
name VARCHAR(150), |
||||
|
active BOOLEAN default 1 not null, |
||||
|
user_id INTEGER |
||||
|
references user |
||||
|
on update cascade on delete set null, |
||||
|
interval INTEGER default 20 not null, |
||||
|
url TEXT, |
||||
|
type VARCHAR(20), |
||||
|
weight INTEGER default 2000, |
||||
|
hostname VARCHAR(255), |
||||
|
port INTEGER, |
||||
|
created_date DATETIME, |
||||
|
keyword VARCHAR(255), |
||||
|
maxretries INTEGER NOT NULL DEFAULT 0 |
||||
|
); |
||||
|
|
||||
|
insert into monitor_dg_tmp(id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword) select id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword from monitor; |
||||
|
|
||||
|
drop table monitor; |
||||
|
|
||||
|
alter table monitor_dg_tmp rename to monitor; |
||||
|
|
||||
|
create index user_id on monitor (user_id); |
||||
|
|
||||
|
COMMIT; |
||||
|
|
||||
|
PRAGMA foreign_keys=on; |
@ -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(); |
@ -0,0 +1,40 @@ |
|||||
|
/** |
||||
|
* String.prototype.replaceAll() polyfill |
||||
|
* https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/
|
||||
|
* @author Chris Ferdinandi |
||||
|
* @license MIT |
||||
|
*/ |
||||
|
if (!String.prototype.replaceAll) { |
||||
|
String.prototype.replaceAll = function(str, newStr){ |
||||
|
|
||||
|
// If a regex pattern
|
||||
|
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') { |
||||
|
return this.replace(str, newStr); |
||||
|
} |
||||
|
|
||||
|
// If a string
|
||||
|
return this.replace(new RegExp(str, 'g'), newStr); |
||||
|
|
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
const pkg = require('../package.json'); |
||||
|
const fs = require("fs"); |
||||
|
const oldVersion = pkg.version |
||||
|
const newVersion = oldVersion + "-nightly" |
||||
|
|
||||
|
console.log("Old Version: " + oldVersion) |
||||
|
console.log("New Version: " + newVersion) |
||||
|
|
||||
|
if (newVersion) { |
||||
|
// Process package.json
|
||||
|
pkg.version = newVersion |
||||
|
pkg.scripts.setup = pkg.scripts.setup.replaceAll(oldVersion, newVersion) |
||||
|
pkg.scripts["build-docker"] = pkg.scripts["build-docker"].replaceAll(oldVersion, newVersion) |
||||
|
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 4) + "\n") |
||||
|
|
||||
|
// Process README.md
|
||||
|
if (fs.existsSync("README.md")) { |
||||
|
fs.writeFileSync("README.md", fs.readFileSync("README.md", 'utf8').replaceAll(oldVersion, newVersion)) |
||||
|
} |
||||
|
} |
@ -1,65 +1,55 @@ |
|||||
{ |
{ |
||||
"name": "uptime-kuma", |
"name": "uptime-kuma", |
||||
"version": "1.2.0", |
"version": "1.0.6", |
||||
|
"license": "MIT", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/louislam/uptime-kuma.git" |
||||
|
}, |
||||
"scripts": { |
"scripts": { |
||||
"dev": "vite --host", |
"dev": "vite --host", |
||||
"start-server": "node server/server.js", |
"start-server": "node server/server.js", |
||||
"update": "", |
"update": "", |
||||
"release": "release-it", |
|
||||
"build": "vite build", |
"build": "vite build", |
||||
"vite-preview-dist": "vite preview --host", |
"vite-preview-dist": "vite preview --host", |
||||
"build-docker": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.0.1 . --push", |
"build-docker": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.0.6 --target release . --push", |
||||
"setup": "git checkout 1.0.1 && npm install && npm run build" |
"build-docker-nightly": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push", |
||||
|
"build-docker-nightly-amd64": "docker buildx build --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push", |
||||
|
"setup": "git checkout 1.0.6 && npm install && npm run build", |
||||
|
"version-global-replace": "node extra/version-global-replace.js", |
||||
|
"mark-as-nightly": "node extra/mark-as-nightly.js" |
||||
}, |
}, |
||||
"dependencies": { |
"dependencies": { |
||||
"@popperjs/core": "2.9.2", |
"@popperjs/core": "^2.9.2", |
||||
"args-parser": "1.3.0", |
"args-parser": "^1.3.0", |
||||
"axios": "0.21.1", |
"axios": "^0.21.1", |
||||
"bcrypt": "5.0.1", |
"bcrypt": "^5.0.1", |
||||
"bootstrap": "5.0.2", |
"bootstrap": "^5.0.2", |
||||
"dayjs": "1.10.6", |
"command-exists": "^1.2.9", |
||||
"express": "4.17.1", |
"dayjs": "^1.10.6", |
||||
"form-data": "4.0.0", |
"express": "^4.17.1", |
||||
"jsonwebtoken": "8.5.1", |
"form-data": "^4.0.0", |
||||
"nodemailer": "6.6.3", |
"http-graceful-shutdown": "^3.1.2", |
||||
"password-hash": "1.2.2", |
"jsonwebtoken": "^8.5.1", |
||||
|
"nodemailer": "^6.6.3", |
||||
|
"password-hash": "^1.2.2", |
||||
"redbean-node": "0.0.20", |
"redbean-node": "0.0.20", |
||||
"socket.io": "4.1.3", |
"socket.io": "^4.1.3", |
||||
"socket.io-client": "4.1.3", |
"socket.io-client": "^4.1.3", |
||||
"tcp-ping": "0.1.1", |
"sqlite3": "^5.0.2", |
||||
"vue": "3.1.4", |
"tcp-ping": "^0.1.1", |
||||
"vue-confirm-dialog": "1.0.2", |
"v-pagination-3": "^0.1.6", |
||||
"vue-router": "4.0.10", |
"vue": "^3.0.5", |
||||
"vue-toastification": "2.0.0-rc.1" |
"vue-confirm-dialog": "^1.0.2", |
||||
|
"vue-router": "^4.0.10", |
||||
|
"vue-toastification": "^2.0.0-rc.1" |
||||
}, |
}, |
||||
"devDependencies": { |
"devDependencies": { |
||||
"@vitejs/plugin-legacy": "1.4.4", |
"@vitejs/plugin-legacy": "^1.4.4", |
||||
"@vitejs/plugin-vue": "1.2.5", |
"@vitejs/plugin-vue": "^1.2.5", |
||||
"@vue/compiler-sfc": "3.1.4", |
"@vue/compiler-sfc": "^3.1.5", |
||||
"auto-changelog": "2.3.0", |
"core-js": "^3.15.2", |
||||
"core-js": "3.15.2", |
"sass": "^1.35.2", |
||||
"release-it": "14.10.0", |
"vite": "^2.4.2" |
||||
"sass": "1.35.2", |
|
||||
"vite": "2.4.2" |
|
||||
}, |
|
||||
"release-it": { |
|
||||
"git": { |
|
||||
"commit": true, |
|
||||
"requireCleanWorkingDir": false, |
|
||||
"commitMessage": "🚀RELEASE v${version}", |
|
||||
"push": false, |
|
||||
"tag": true, |
|
||||
"tagName": "v${version}", |
|
||||
"tagAnnotation": "v${version}" |
|
||||
}, |
|
||||
"npm": { |
|
||||
"publish": false |
|
||||
}, |
|
||||
"hooks": { |
|
||||
"after:bump": "auto-changelog --commit-limit false -p -u --hide-credit && git add CHANGELOG.md" |
|
||||
} |
|
||||
}, |
|
||||
"volta": { |
|
||||
"node": "16.4.2" |
|
||||
} |
} |
||||
} |
} |
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,3 @@ |
|||||
|
# https://www.robotstxt.org/robotstxt.html |
||||
|
User-agent: * |
||||
|
Disallow: |
@ -0,0 +1,119 @@ |
|||||
|
const fs = require("fs"); |
||||
|
const {sleep} = require("./util"); |
||||
|
const {R} = require("redbean-node"); |
||||
|
const {setSetting, setting} = require("./util-server"); |
||||
|
|
||||
|
|
||||
|
class Database { |
||||
|
|
||||
|
static templatePath = "./db/kuma.db" |
||||
|
static path = './data/kuma.db'; |
||||
|
static latestVersion = 1; |
||||
|
static noReject = true; |
||||
|
|
||||
|
static async patch() { |
||||
|
let version = parseInt(await setting("database_version")); |
||||
|
|
||||
|
if (! version) { |
||||
|
version = 0; |
||||
|
} |
||||
|
|
||||
|
console.info("Your database version: " + version); |
||||
|
console.info("Latest database version: " + this.latestVersion); |
||||
|
|
||||
|
if (version === this.latestVersion) { |
||||
|
console.info("Database no need to patch"); |
||||
|
} else { |
||||
|
console.info("Database patch is needed") |
||||
|
|
||||
|
console.info("Backup the db") |
||||
|
const backupPath = "./data/kuma.db.bak" + version; |
||||
|
fs.copyFileSync(Database.path, backupPath); |
||||
|
|
||||
|
// Try catch anything here, if gone wrong, restore the backup
|
||||
|
try { |
||||
|
for (let i = version + 1; i <= this.latestVersion; i++) { |
||||
|
const sqlFile = `./db/patch${i}.sql`; |
||||
|
console.info(`Patching ${sqlFile}`); |
||||
|
await Database.importSQLFile(sqlFile); |
||||
|
console.info(`Patched ${sqlFile}`); |
||||
|
await setSetting("database_version", i); |
||||
|
} |
||||
|
console.log("Database Patched Successfully"); |
||||
|
} catch (ex) { |
||||
|
await Database.close(); |
||||
|
console.error("Patch db failed!!! Restoring the backup") |
||||
|
fs.copyFileSync(backupPath, Database.path); |
||||
|
console.error(ex) |
||||
|
|
||||
|
console.error("Start Uptime-Kuma failed due to patch db failed") |
||||
|
console.error("Please submit the bug report if you still encounter the problem after restart: https://github.com/louislam/uptime-kuma/issues") |
||||
|
process.exit(1); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Sadly, multi sql statements is not supported by many sqlite libraries, I have to implement it myself |
||||
|
* @param filename |
||||
|
* @returns {Promise<void>} |
||||
|
*/ |
||||
|
static async importSQLFile(filename) { |
||||
|
|
||||
|
await R.getCell("SELECT 1"); |
||||
|
|
||||
|
let text = fs.readFileSync(filename).toString(); |
||||
|
|
||||
|
// Remove all comments (--)
|
||||
|
let lines = text.split("\n"); |
||||
|
lines = lines.filter((line) => { |
||||
|
return ! line.startsWith("--") |
||||
|
}); |
||||
|
|
||||
|
// Split statements by semicolon
|
||||
|
// Filter out empty line
|
||||
|
text = lines.join("\n") |
||||
|
|
||||
|
let statements = text.split(";") |
||||
|
.map((statement) => { |
||||
|
return statement.trim(); |
||||
|
}) |
||||
|
.filter((statement) => { |
||||
|
return statement !== ""; |
||||
|
}) |
||||
|
|
||||
|
for (let statement of statements) { |
||||
|
await R.exec(statement); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Special handle, because tarn.js throw a promise reject that cannot be caught |
||||
|
* @returns {Promise<void>} |
||||
|
*/ |
||||
|
static async close() { |
||||
|
const listener = (reason, p) => { |
||||
|
Database.noReject = false; |
||||
|
}; |
||||
|
process.addListener('unhandledRejection', listener); |
||||
|
|
||||
|
console.log("Closing DB") |
||||
|
|
||||
|
while (true) { |
||||
|
Database.noReject = true; |
||||
|
await R.close() |
||||
|
await sleep(2000) |
||||
|
|
||||
|
if (Database.noReject) { |
||||
|
break; |
||||
|
} else { |
||||
|
console.log("Waiting to close the db") |
||||
|
} |
||||
|
} |
||||
|
console.log("SQLite closed") |
||||
|
|
||||
|
process.removeListener('unhandledRejection', listener); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = Database; |
Loading…
Reference in new issue