beakerbrowser / beaker

An experimental peer-to-peer Web browser
https://beakerbrowser.com/
MIT License
6.75k stars 545 forks source link

Run daemon at start-up #1665

Open da2x opened 4 years ago

da2x commented 4 years ago

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:

(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.

matthewauld commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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

pfrazee commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

@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)