mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-07-05 03:55:13 +08:00
feat: 环境变量 SUB_STORE_DATA_URL
启动时自动从此地址拉取并恢复数据
This commit is contained in:
parent
e05475aa5e
commit
ce6cd794c8
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.126",
|
"version": "2.14.127",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import express from '@/vendor/express';
|
import express from '@/vendor/express';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
|
import migrate from '@/utils/migration';
|
||||||
|
import download from '@/utils/download';
|
||||||
|
|
||||||
import registerSubscriptionRoutes from './subscriptions';
|
import registerSubscriptionRoutes from './subscriptions';
|
||||||
import registerCollectionRoutes from './collections';
|
import registerCollectionRoutes from './collections';
|
||||||
@ -41,6 +43,7 @@ export default function serve() {
|
|||||||
if ($.env.isNode) {
|
if ($.env.isNode) {
|
||||||
const path = eval(`require("path")`);
|
const path = eval(`require("path")`);
|
||||||
const fs = eval(`require("fs")`);
|
const fs = eval(`require("fs")`);
|
||||||
|
const data_url = eval('process.env.SUB_STORE_DATA_URL');
|
||||||
const fe_be_path = eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH');
|
const fe_be_path = eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH');
|
||||||
const fe_port = eval('process.env.SUB_STORE_FRONTEND_PORT') || 3001;
|
const fe_port = eval('process.env.SUB_STORE_FRONTEND_PORT') || 3001;
|
||||||
const fe_host =
|
const fe_host =
|
||||||
@ -133,5 +136,23 @@ export default function serve() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (data_url) {
|
||||||
|
$.info(`[BACKEND] downloading data from ${data_url}`);
|
||||||
|
download(data_url)
|
||||||
|
.then((content) => {
|
||||||
|
$.write(content, '#sub-store');
|
||||||
|
|
||||||
|
$.cache = JSON.parse(content);
|
||||||
|
$.persistCache();
|
||||||
|
|
||||||
|
migrate();
|
||||||
|
$.info(`[BACKEND] restored data from ${data_url}`);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
$.error(`[BACKEND] restore data failed`);
|
||||||
|
console.error(e);
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user