Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Run daemon at start-up #1665

Open
da2x opened this issue May 24, 2020 · 8 comments
Open

Run daemon at start-up #1665

da2x opened this issue May 24, 2020 · 8 comments
Assignees
Labels
enhancement Change that's on the roadmap PRs welcome!

Comments

@da2x
Copy link
Contributor

da2x commented May 24, 2020

Is your feature request related to a problem? Please describe.
Increase peer participation and hyperdrive availability.

Describe the solution you'd like
Start the daemon on start-up and let it run indefinitely without starting Beaker.

Pause the daemon in any of these conditions:

  • Beaker isn’t running and the device is powered from battery.
  • Beaker isn’t running and the device’s is on a metered network connection.

(There are APIs for both of these on Linux, macOS, and Windows.)

Describe alternatives you've considered
The status-quo.

Secondary: Updates
Auto-updates should probably be moved out into this background daemon.

@da2x da2x added the feature request Suggested change that's under consideration but not yet on the roadmap label May 24, 2020
@pfrazee pfrazee self-assigned this May 25, 2020
@pfrazee pfrazee added enhancement Change that's on the roadmap and removed feature request Suggested change that's under consideration but not yet on the roadmap labels Jun 4, 2020
@matthewauld
Copy link
Contributor

I can take a crack at this if it would be helpful. Basically add a setting that if enabled would launch the PM2 with noPM2DaemonMode set to false, and if disabled, kill the running hyperdrive-daemon and restart it with noPM2DaemonMode set to true? We can display a confirmation window, as this would need to be a "restart beaker to on change" type request.

The pausing on battery and metered service is a neat idea, but I think it would need to be implemented in the hyperdrive-daemon first, as it would need to operate when beaker is closed, and would effect all other clients using the daemon.

@pfrazee
Copy link
Member

pfrazee commented Jun 12, 2020

@matthewauld +1 for you to hit this but it actually would require a different approach - you need to start beaker, not something else.

It looks like for windows and mac we can use a builtin API (https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows). For linux we may need to use https://www.npmjs.com/package/auto-launch

@matthewauld
Copy link
Contributor

Ah, OK - so you want beaker to keep the daemon running - sounds good. I can take a look.

@pfrazee
Copy link
Member

pfrazee commented Jun 12, 2020

Yeah it's somewhat confusing but Beaker actively manages hyperdrive-daemon and ties its lifecycle together. When you close Beaker to the tray, Beaker stays running.

@matthewauld
Copy link
Contributor

So, just so I know I am on the right track with this: I would need to expose the
setBeakerAtStartup(bool) function (or whatever I call it) through the browser object in browser.js, so that when the user toggles the setting the change is made, right?
And I am guessing also we would check to ensure that autostart is set correctly at each startup?

@pfrazee
Copy link
Member

pfrazee commented Jun 18, 2020

@matthewauld that sounds right, since it's more than just a setting in the internal settings db, putting a method on the browser internal RPC should be the way to go

@matthewauld
Copy link
Contributor

@pfrazee sorry this has taken so long - got sidetracked this week.
I have it working on linux and will test on mac a little later today. I don't have a windows box

Currently it only checks to ensure "launch on startup" is set correctly when you actually change the setting, but they could get out of sync, say, if a user removes beaker from the startup list in the OS. To fix that I was just going to write some code that ensured they were in sync every time beaker starts up - I just don't know where the best place to put "run on program start" stuff is - should it be in main.js, browser.js setup function, or somewhere else?

I can package that up as a pull request and then figure out the metered connection and battery options.

@pfrazee
Copy link
Member

pfrazee commented Jun 21, 2020

@matthewauld No need to apologize! Contributions are gifts, not obligations

I think you've got a handle on things. Just make the call on where to put that code and I'll review the PR. No big deal to make changes (and I'm happy to make changes on things like that rather than punt back to you)

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement Change that's on the roadmap PRs welcome!
Projects
None yet
Development

No branches or pull requests

3 participants