mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 09:16:16 +00:00
feat: add standalone dashboard for bot monitoring and control
- Introduced a new dashboard feature with endpoints for bot status, account management, logs, and configuration. - Added support for starting the dashboard server via command line and configuration options. - Implemented WebSocket support for real-time log streaming to the dashboard. - Enhanced configuration management to include dashboard settings. - Updated package.json to include new dependencies and scripts for dashboard functionality. - Added tests for dashboard state management and functionality.
This commit is contained in:
23
src/index.ts
23
src/index.ts
@@ -1322,11 +1322,34 @@ function formatDuration(ms: number): string {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Check for dashboard mode flag (standalone dashboard)
|
||||
if (process.argv.includes('-dashboard')) {
|
||||
const { startDashboardServer } = await import('./dashboard/server')
|
||||
log('main', 'DASHBOARD', 'Starting standalone dashboard server...')
|
||||
startDashboardServer()
|
||||
return
|
||||
}
|
||||
|
||||
const rewardsBot = new MicrosoftRewardsBot(false)
|
||||
|
||||
const crashState = { restarts: 0 }
|
||||
const config = rewardsBot.config
|
||||
|
||||
// Auto-start dashboard if enabled in config
|
||||
if (config.dashboard?.enabled) {
|
||||
const { DashboardServer } = await import('./dashboard/server')
|
||||
const port = config.dashboard.port || 3000
|
||||
const host = config.dashboard.host || '127.0.0.1'
|
||||
|
||||
// Override env vars with config values
|
||||
process.env.DASHBOARD_PORT = String(port)
|
||||
process.env.DASHBOARD_HOST = host
|
||||
|
||||
const dashboardServer = new DashboardServer()
|
||||
dashboardServer.start()
|
||||
log('main', 'DASHBOARD', `Auto-started dashboard on http://${host}:${port}`)
|
||||
}
|
||||
|
||||
const attachHandlers = () => {
|
||||
process.on('unhandledRejection', (reason: unknown) => {
|
||||
log('main','FATAL','UnhandledRejection: ' + (reason instanceof Error ? reason.message : String(reason)), 'error')
|
||||
|
||||
Reference in New Issue
Block a user