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

Make Linux UI logging behave like other platforms #12488

Merged
merged 8 commits into from
Jun 27, 2018

Conversation

akalin-keybase
Copy link
Contributor

@akalin-keybase akalin-keybase commented Jun 21, 2018

This should cause UI logs to be uploaded on Linux (!).

@akalin-keybase akalin-keybase requested a review from a team June 21, 2018 18:25
@akalin-keybase
Copy link
Contributor Author

r? @keybase/react-hackers cc @mmaxim

@akalin-keybase
Copy link
Contributor Author

Not sure how to test this end-to-end except cutting a new Linux release and then using that, but I've verified that opening the app dumps logs to the file.

@@ -140,7 +140,7 @@ function logFileName(): string {
case 'darwin':
return `${logDir()}/${envedPathOSX[runMode]}.app.log`
case 'linux':
return '' // Linux is '' because we can redirect stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

This has been around for a really long time, right? Did something change recently that caused the logs not to get written properly? Or was this stuff always broken on Linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap, been around for a while. Now that I think about it, I've seen the 'context deadline exceeded' error before when doing log send on Linux, so it seems to me that this was just always broken. 😱

Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't be broken, or at least not in the systemd case:

ExecStart=/usr/bin/env bash -c "/opt/keybase/Keybase &>> %h/.cache/keybase/Keybase.app.log"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, yeah looks like I misdiagnosed the original problem. The file does exist and is being upload -- the problem is that the UI log lines aren't being sent to stdout.

@akalin-keybase
Copy link
Contributor Author

Discussed a bit with @chrisnojima but we should probably discuss on Monday when @oconnor663 gets back.

Copy link
Contributor

@jzila jzila left a comment

Choose a reason for hiding this comment

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

argh, commenting to remove this from my review-requested list

@oconnor663
Copy link
Contributor

@akalin-keybase should we do a hangout sometime today?

@akalin-keybase
Copy link
Contributor Author

Chatted with @oconnor663, we decided that I'd try removing the stdout logging and make logFileName return a non-empty path.

@@ -97,7 +97,7 @@ func updaterBinName() (string, error) {

// RunApp starts the app
func RunApp(context Context, log Log) error {
// TODO: Start app, see run_keybase: /opt/keybase/Keybase &>> "$logdir/Keybase.app.log"
// TODO: Start app, see run_keybase: /opt/keybase/Keybase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this comment still applies but fixed it anyway

@@ -4,8 +4,7 @@ Wants=keybase.service kbfs.service

[Service]
Type=simple
ExecStartPre=/usr/bin/env mkdir -p %h/.cache/keybase
ExecStart=/usr/bin/env bash -c "/opt/keybase/Keybase &>> %h/.cache/keybase/Keybase.app.log"
ExecStart=/opt/keybase/Keybase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need for the ExecStartPre since we create the log dir before dumping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

random thought...will this be affected by the electron bug that makes us redirect output to avoid a black screen?

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds like a scary bug. Stdout is affecting what gets drawn on the screen?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's super weird: electron/electron#12850

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, tested that it still works.

case 'win32':
return `${getenv('LOCALAPPDATA', '')}\\${envedPathWin32[runMode]}`
}
throw new Error(`Unknown platform ${process.platform}`)
}

function logFileName(): string {
// See DesktopLogFileName in go/libkb/constants.go.
//
// TODO: darwin and win32 cases are inconsistent with
Copy link
Contributor Author

Choose a reason for hiding this comment

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

darwin just happens to work for prod mode. not sure why win32 isn't bitten by the difference in case. @zanderz do you know?

@@ -123,24 +123,31 @@ function findCacheRoot(): string {
}

function logDir(): string {
// See LogDir() functions in go/libkb/home.go.
//
// TODO: darwin and win32 cases are inconsistent with their LogDir()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

darwin just happens to work for prod mode, and so does win32 I'm guessing (do APPDATA and LOCALAPPDATA usually coincide?)

@akalin-keybase akalin-keybase changed the title Have logFileName return something on Linux Make Linux UI logging behave like other platforms Jun 25, 2018
@akalin-keybase
Copy link
Contributor Author

Okay, this should be ready again for review @oconnor663 @jzila and @keybase/react-hackers

switch (process.platform) {
case 'darwin':
return `${getenv('HOME', '')}/Library/Logs`
case 'linux':
const linuxDefaultRoot = `${getenv('HOME', '')}/.local/share`
return `${getenv('XDG_DATA_HOME', linuxDefaultRoot)}/${envedPathLinux[runMode]}`
return findCacheRoot()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

~/.local/share is the wrong place to put logs. Note that this also changes jsonDebugFileName

Copy link
Contributor

@oconnor663 oconnor663 left a comment

Choose a reason for hiding this comment

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

LGTM!

@oconnor663
Copy link
Contributor

@akalin-keybase akalin-keybase requested a review from a team June 26, 2018 17:27
@akalin-keybase
Copy link
Contributor Author

bump (from @keybase/react-hackers)

@akalin-keybase akalin-keybase merged commit 7629cd5 into master Jun 27, 2018
@akalin-keybase akalin-keybase deleted the akalin/DESKTOP-7136 branch June 27, 2018 19:16
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.

3 participants