mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 02:57:34 +00:00
feat: add restart time for leaking Chromium in Ubuntu (#1880)
docs: add documentation for RESTART_TIME
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
| `PROXY_PROTOCOL` | Protocol of proxy server, such as `socks5`. Default: `http` |
|
| `PROXY_PROTOCOL` | Protocol of proxy server, such as `socks5`. Default: `http` |
|
||||||
| `PROXY_ADDRESS` | IP Address or fqdn of proxy server |
|
| `PROXY_ADDRESS` | IP Address or fqdn of proxy server |
|
||||||
| `PROXY_PORT` | TCP Port number on which the proxy is listening for connections. Default: `80` |
|
| `PROXY_PORT` | TCP Port number on which the proxy is listening for connections. Default: `80` |
|
||||||
|
| `RESTART_TIME` | Restarts chrome after defined milliseconds. `0` for never, default: `0` |
|
||||||
| `SCREENSHOT` | Capture screenshot of page if a card is found. Default: `true` |
|
| `SCREENSHOT` | Capture screenshot of page if a card is found. Default: `true` |
|
||||||
| `WEB_PORT` | Starts a webserver to be able to control the bot while it is running. Setting this value starts this service. |
|
| `WEB_PORT` | Starts a webserver to be able to control the bot while it is running. Setting this value starts this service. |
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ PUSHOVER_RETRY=
|
|||||||
PUSHOVER_TOKEN=
|
PUSHOVER_TOKEN=
|
||||||
PUSHOVER_USER=
|
PUSHOVER_USER=
|
||||||
PUSHOVER_PRIORITY=
|
PUSHOVER_PRIORITY=
|
||||||
|
RESTART_TIME=
|
||||||
SCREENSHOT=
|
SCREENSHOT=
|
||||||
SHOW_ONLY_BRANDS=
|
SHOW_ONLY_BRANDS=
|
||||||
SHOW_ONLY_MODELS=
|
SHOW_ONLY_MODELS=
|
||||||
|
|||||||
@@ -439,6 +439,8 @@ const store = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const restartTime = envOrNumber(process.env.RESTART_TIME, 0);
|
||||||
|
|
||||||
export const defaultStoreData = {
|
export const defaultStoreData = {
|
||||||
maxPageSleep: browser.maxSleep,
|
maxPageSleep: browser.maxSleep,
|
||||||
minPageSleep: browser.minSleep,
|
minPageSleep: browser.minSleep,
|
||||||
@@ -453,6 +455,7 @@ export const config = {
|
|||||||
page,
|
page,
|
||||||
proxy,
|
proxy,
|
||||||
store,
|
store,
|
||||||
|
restartTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function setConfig(newConfig: any) {
|
export function setConfig(newConfig: any) {
|
||||||
|
|||||||
@@ -13,6 +13,21 @@ puppeteer.use(stealthPlugin());
|
|||||||
|
|
||||||
let browser: Browser | undefined;
|
let browser: Browser | undefined;
|
||||||
|
|
||||||
|
async function sleep(ms: number) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedules a restart of the bot
|
||||||
|
*/
|
||||||
|
async function restartMain() {
|
||||||
|
if (config.restartTime > 0) {
|
||||||
|
await sleep(config.restartTime);
|
||||||
|
await stop();
|
||||||
|
loopMain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the bot.
|
* Starts the bot.
|
||||||
*/
|
*/
|
||||||
@@ -92,6 +107,7 @@ async function stopAndExit() {
|
|||||||
*/
|
*/
|
||||||
async function loopMain() {
|
async function loopMain() {
|
||||||
try {
|
try {
|
||||||
|
restartMain();
|
||||||
await main();
|
await main();
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user