Upgrade improvements and refactor shutdown process #20
Closed
alexliebowitz wants to merge 7 commits from
upgrades-2
into master
pull from: upgrades-2
merge into: LBRYCommunity:master
LBRYCommunity:master
LBRYCommunity:dependabot/npm_and_yarn/electron-22.3.21
LBRYCommunity:dependabot/npm_and_yarn/semver-5.7.2
LBRYCommunity:7681-remove-block-list-apis
LBRYCommunity:new-sync-demo-no-user
LBRYCommunity:commentserver-swap-test-2
LBRYCommunity:Comment-server-swap
LBRYCommunity:7683-upgrade-to-electron-20
LBRYCommunity:7668-improve-startup-performance-while-fetching-comment-moderation-info
LBRYCommunity:feat-exportWalletSync
LBRYCommunity:feat-walletExport
LBRYCommunity:new-sync-demo
LBRYCommunity:test-updates4b
LBRYCommunity:test-updates-4a
LBRYCommunity:update-test-3c
LBRYCommunity:update-test-3b
LBRYCommunity:update-test-3
LBRYCommunity:test7495b2
LBRYCommunity:test7495a2
LBRYCommunity:test7495b
LBRYCommunity:test7495
LBRYCommunity:test109
LBRYCommunity:test-sdk-109
LBRYCommunity:feat-restoreLocalNotifications
LBRYCommunity:test-gatekeeper
LBRYCommunity:test-107
LBRYCommunity:test-mac-notarize
LBRYCommunity:update-postcss-quagmire
LBRYCommunity:testpush
LBRYCommunity:commentApiDefault
LBRYCommunity:inspect-upgrades
LBRYCommunity:fix-unblockIsChannelClaim
LBRYCommunity:ody255
LBRYCommunity:robd-mac-2
LBRYCommunity:sso-demo
LBRYCommunity:robd-universal
LBRYCommunity:remove-swap
LBRYCommunity:cleaning.dec.21
LBRYCommunity:update-trending-param
LBRYCommunity:collection-ordering
LBRYCommunity:download-progress
LBRYCommunity:anton
LBRYCommunity:anthony-fix-video-ios
LBRYCommunity:saltdev
LBRYCommunity:bump-electron-to-11
LBRYCommunity:fix-noBlockSubmitOnImgError
LBRYCommunity:x.lint.extras
LBRYCommunity:x.final
LBRYCommunity:somehow-working
LBRYCommunity:reenable-ads
LBRYCommunity:issue/7152
LBRYCommunity:chat-markdown
LBRYCommunity:ip/muted.uris
LBRYCommunity:odysee-split
LBRYCommunity:feat-desktopRelated
LBRYCommunity:ip/memo
LBRYCommunity:bs
LBRYCommunity:ip/memoization
LBRYCommunity:bump-flow-version
LBRYCommunity:ip/shared.block.list
LBRYCommunity:keycloak-sso
LBRYCommunity:a-r-w-k-2
LBRYCommunity:auth-refactor-w-keycloak
LBRYCommunity:auth-refactor
LBRYCommunity:rb-ip/embed-replay
LBRYCommunity:issue/2120
LBRYCommunity:oidc
LBRYCommunity:fix-videojs-ios
LBRYCommunity:fiat-tip-improvements
LBRYCommunity:test-tom-1
LBRYCommunity:fix-videojs-issues
LBRYCommunity:fix-persistSupportOption
LBRYCommunity:ctrl-txt
LBRYCommunity:add-play-button-on-pause-ios
LBRYCommunity:mobile-ui-bugfix-for-preview-images
LBRYCommunity:fix-livestream-claim-type
LBRYCommunity:playback-controls-2
LBRYCommunity:copy-list
LBRYCommunity:feat-collection-background-publishing
LBRYCommunity:ip/repost.in.homepage
LBRYCommunity:wallet-iteration-2
LBRYCommunity:broken-ads-branch
LBRYCommunity:move-stripe-transactions-to-wallet-fix
LBRYCommunity:lint.autoformat
LBRYCommunity:jessop-stripe
LBRYCommunity:move-transactions
LBRYCommunity:stripe-move-transactions-to-wallet
LBRYCommunity:mater
LBRYCommunity:more-stripe-integration
LBRYCommunity:more-stripe-integration1
LBRYCommunity:desktop-redirect
LBRYCommunity:rss-test
LBRYCommunity:fixed-collectionEdit
LBRYCommunity:watchman-plugin-odysee-anthony
LBRYCommunity:grin
LBRYCommunity:watchman-plugin-odysee
LBRYCommunity:protocol
LBRYCommunity:salt_saved_list
LBRYCommunity:salt-saved_list
LBRYCommunity:watchman-plugin
LBRYCommunity:more-stripe-integration2
LBRYCommunity:salt-savedList
LBRYCommunity:salt/mobile-comments
LBRYCommunity:chromecast-test2
LBRYCommunity:odysee
LBRYCommunity:wpe-on-ody
LBRYCommunity:bring-back-subtitles-button
LBRYCommunity:merge-to-odysee
LBRYCommunity:bugfix-tip-error
LBRYCommunity:popup-fix
LBRYCommunity:favi-cherry
LBRYCommunity:searchDefaults
LBRYCommunity:pin-from-homepages-master
LBRYCommunity:ody-7-22-c
LBRYCommunity:ody-7-22-b
LBRYCommunity:ody-7-22
LBRYCommunity:ody-7-21
LBRYCommunity:cherry.pick.thumbs.fix
LBRYCommunity:ody-rb-7-20c
LBRYCommunity:test-chromecast
LBRYCommunity:ody-7-20-rb
LBRYCommunity:odysee-cnsearch
LBRYCommunity:ody-7-19-b
LBRYCommunity:anthony-odysee
LBRYCommunity:drewhancock-patch-2
LBRYCommunity:horizon-server
LBRYCommunity:feat-nicer-outages
LBRYCommunity:tech-debt/selectors-search
LBRYCommunity:fix-lbry-tv-thumbnails
LBRYCommunity:drewhancock-patch-1
LBRYCommunity:jbnrecsys
LBRYCommunity:feat/disableListEditPending
LBRYCommunity:testapi
LBRYCommunity:bump-lightouse-throttle
LBRYCommunity:popup
LBRYCommunity:replays-rebased-tom
LBRYCommunity:pre-reoll-ads-rebase
LBRYCommunity:julianchandra-patch-1
LBRYCommunity:feat/better-chat
LBRYCommunity:revert-livestream
LBRYCommunity:feat/code-splitting
LBRYCommunity:feat/go-live-forms
LBRYCommunity:UI/drop-down-menu-animation
LBRYCommunity:faster-builds
No reviewers
Labels
Clear labels
Work is part of a proposal
Beamer is waiting on you!
Discuss this issue at the next planning meeting, then remove this label
Welcome to Hacktoberfest
Long-term storage
No knowledge of the existing code required
Some knowledge of the existing code is recommended
Significant knowledge of the existing code is recommended
Intimate knowledge of the existing code is recommended
Solution unclear, needs research
Issue needs to be groomed before work can start
Priority level needs to be defined
Issue needs step-by-step instructions on how to reproduce in latest code
Needs technical design signoff before implementation can begin
Temporarily paused
Issue is blocking release, do ASAP
Work needs to be moved into sprint ASAP
Work should be done but can stay in the backlog for now
Work needs to be done within 2-3 sprints
general redesign not prioritize for anyone release
Requires work on lbry-sdk repo
Existing functionality is wrong or broken
A conversation. No specific changes requested
Existing (or partially existing) functionality needs to be changed
New functionality that does not exist yet
Minimal user-visible changes, but significant internal work
Either work that's not related to the code, or a small chore that does not fit into other categories
Solution needs additional user testing
Work that was not planned into the spirnt, took priority over planned work
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
Work is part of a proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
Beamer is waiting on you!
channel
comments
community PR
consider soon
Discuss this issue at the next planning meeting, then remove this label
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
Welcome to Hacktoberfest
help wanted
hub-dependent
icebox
Long-term storage
Invalid
level: 0
level: 1
No knowledge of the existing code required
level: 2
Some knowledge of the existing code is recommended
level: 3
Significant knowledge of the existing code is recommended
level: 4
Intimate knowledge of the existing code is recommended
merge when green
needs: exploration
Solution unclear, needs research
needs: grooming
Issue needs to be groomed before work can start
needs: priority
Priority level needs to be defined
needs: repro
Issue needs step-by-step instructions on how to reproduce in latest code
needs: tech design
Needs technical design signoff before implementation can begin
notifications
odysee
on hold
Temporarily paused
playlists
priority: blocker
Issue is blocking release, do ASAP
priority: high
Work needs to be moved into sprint ASAP
priority: low
Work should be done but can stay in the backlog for now
priority: medium
Work needs to be done within 2-3 sprints
protocol dependent
recsys
redesign
general redesign not prioritize for anyone release
regression
resilience
sdk dependent
Requires work on lbry-sdk repo
Tom's Wishlist
trending
type: bug
Existing functionality is wrong or broken
type: discussion
A conversation. No specific changes requested
type: improvement
Existing (or partially existing) functionality needs to be changed
type: new feature
New functionality that does not exist yet
type: refactor
Minimal user-visible changes, but significant internal work
type: task
Either work that's not related to the code, or a small chore that does not fit into other categories
type: testing
Solution needs additional user testing
unplanned
Work that was not planned into the spirnt, took priority over planned work
windows
No labels
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
channel
comments
community PR
consider soon
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
help wanted
hub-dependent
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
merge when green
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
notifications
odysee
on hold
playlists
priority: blocker
priority: high
priority: low
priority: medium
protocol dependent
recsys
redesign
regression
resilience
sdk dependent
Tom's Wishlist
trending
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
windows
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry-desktop#20
Reference in a new issue
No description provided.
Delete branch "upgrades-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
xdg-open
instead of usingshell.openItem()
, which doesn't reliably work from the main processOutstanding issues before ready to merge:
xdg-open
doesn't work reliably if you're not the same user as the package manager.shell.openItem()
would have the same problem as it ultimately just calls xdg-open. We should probably at least detect this scenario and do something different, e.g. reveal the file instead of open it, and display a notice that you'll have to click the file to start the upgrade.@ -89,2 +173,4 @@
}
// Quit when all windows are closed.
does this work on osx and windows? or is this only called on linux?
also, i find it hard to believe that we cant tell whether this worked or failed
wait, so this will to force-kill all daemons no matter what, even if the appropriate daemon was stopped successfully?
@ -89,2 +173,4 @@
}
// Quit when all windows are closed.
It's called everywhere, but yesterday I factored this out and made it choose the command based on OS. That'll go up with my next set of changes.
Re: checking if it worked or failed, we can detect some failure conditions (where the installer or package manager completely fails to launch, arguably the least likely scenario) by seeing if the process returns with an error status code. But we can't detect anything that happens after that, like getting that weird dialog box because of a user mismatch. But you're right, I'll add a check for an error code.
The problem is that we don't know which one is the appropriate one, unless we launched it, which we didn't necessarily.
We talked about finding the process listening on 5279 instead, but we don't want to risk killing someone else's process.
Hmm... what if we combined both: we keep this code to get a list of pids for all running lbrynet-daemons, then find the process listening on 5279, confirm it's in the list of daemon pids, then kill just that one? That should handle every scenario except the case where someone made their own app that happens be called "lbrynet-daemon" and also runs on 5279, in which case it's kind of their problem :P
im still confused. we have
client
, which is the connection to the daemon that we use for everything. we calldaemon_stop
on it. your comment sayswe could get an error because the daemon is already stopped
. if the daemon is already stopped, then we're good, right? why do we then try to kill all the running daemons?@ -89,2 +173,4 @@
}
// Quit when all windows are closed.
gotcha
It could be either way. The daemon process could be open but still it's refusing connections, or timing out, or giving 500 errors. Even if the error is "connection refused," it could be frozen but still have the port bound. There's no way to know for sure, just from the response to that call, whether we successfully killed it. But we could get pretty much the same effect by looking at all running processes called "lbrynet-daemon" and finding the one that is listening on 5279 (if any).
On a related note, even in the case where we spawned the daemon ourselves, we don't know if that's the one that we're talking to. I believe jayson does a separate HTTP request for every call, so it's possible that we started the daemon, it crashed, and the user manually started a new one.
@ -65,3 +121,4 @@
app.on('ready', function(){
launchDaemonIfNotRunning();
We could probably use Promises to simplify the shutdown process so we're not calling quitNow in so many places, but for now my goal is to make the logic extremely explicit and easy to reason about.
You sure about that last part? I'm pretty sure that if the daemon crashes, the app will close. See https://github.com/lbryio/lbry-app/blob/master/app/main.js#L46
didnt run this yet (tell me when its ready ready), but it definitely feels like you understand the shutdown process better
@ -18,0 +53,4 @@
['/fi', `Imagename eq ${name}.exe`, '/nh'],
{encoding: 'utf8'}
).stdout;
return tasklistOut.match(/[^\n]+/g).map((line) => line.split(/\s+/)[1]); // Second column of every non-empty line
What does this mean?
Did not display
?@ -65,3 +121,4 @@
app.on('ready', function(){
launchDaemonIfNotRunning();
is this cross-platform?
@ -98,12 +184,15 @@ app.on('window-all-closed', () => {
reminder to remove this before merging
we dont need this anymore?
should now be msi?
Good point. Scratch that part. (Not sure if that actually means anything needs to change with the logic here, though.)
@ -18,0 +53,4 @@
['/fi', `Imagename eq ${name}.exe`, '/nh'],
{encoding: 'utf8'}
).stdout;
return tasklistOut.match(/[^\n]+/g).map((line) => line.split(/\s+/)[1]); // Second column of every non-empty line
No idea where that came from. Maybe just a copy-and-paste error. I meant for it to say something like "did not intentionally quit daemon, so scheduling quit."
I was going on Job's old comment about how the installer is now an MSI (deleted in this PR). But I guess that was written before we switched to Electron, and we're back to an exe.
@ -65,3 +121,4 @@
app.on('ready', function(){
launchDaemonIfNotRunning();
It'll work on Mac and Linux. Still thinking about Windows.
Nope. The UI used to request the quit after an upgrade, but it was moved into upgrade() here in the main process.
merged
Pull request closed