Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use websocket (nchan) instead of ajax polling to refresh data in dashboard #28

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Peuuuur-Noel
Copy link

@Peuuuur-Noel Peuuuur-Noel commented May 4, 2024

  • Use websocket (nchan) instead of ajax polling to refresh data in dashboard
  • All apps usage statuses are no longer sent, only active apps

…shboard

- All apps usage statuses are no longer sent, only active apps
@Peuuuur-Noel
Copy link
Author

Forgot to mention it, but you have to chmod +x /usr/local/emhttp/plugins/gpustat/nchan/gpustat.


// Restart nchan gpustat if not running when refresh setting set to Yes
$pid = exec('pgrep gpustat');
if (!$pid && $_POST['UIREFRESH'] == '1' && $gpustat_cfg['UIREFRESH'] != '1') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be started automatically when you go back to the dashboard so not sure if this is needed. There is a file in var/run called nchan.pid which contains the running nchan processes but would need to confirm the correct way to stop a process.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it too, but monitor_nchan doesn't restart it if path to gpustat is present in /var/run/nchan.pid.
I didn't find a proper way to stop a nchan process. The only way to stop a process is by adding :stop in .page header to nchan attribut, but it's only for a single run. Process killed after 30 seconds.

I made change to remove process path in nchan.pid and stop process itself if refresh set to No. Dashboard will restart it every time if necessary.
Removed code from GPUStatSettings.page and updated here:

// Stop nchan gpustat if refresh setting set to No and remove it from /var/run/nchan.pid
if ($gpustat_cfg['UIREFRESH'] != '1') {
exec('sed -i "/plugins\/gpustat\/nchan\/gpustat/d" /var/run/nchan.pid');
exit;
}

@@ -113,9 +113,19 @@ private function detectApplication (SimpleXMLElement $process)
}
}
}
$this->pageData[$app . 'using'] = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These would still be required for non multi i.e. pre 6.12 unless same changes are applied to the pages and js as this common for both.

Copy link
Author

@Peuuuur-Noel Peuuuur-Noel May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also updated code for pre 6.12.
Both versions (multigpu and non multigpu) use websocket.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nchan can only be used if os is 6.10 or greater. Not sure if there will be users running pre 6.10 Non multy should use ajax updates for backwards compatibilty.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert it and use ajax polling for non multigpu. Sorry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted to ajax polling for non multi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants