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

Some runtime options are applied too late #103

Open
kakra opened this issue Jan 3, 2019 · 2 comments · May be fixed by #136
Open

Some runtime options are applied too late #103

kakra opened this issue Jan 3, 2019 · 2 comments · May be fixed by #136

Comments

@kakra
Copy link
Contributor

kakra commented Jan 3, 2019

Some options like --no-timestamps are applied too late, bees may already have logged something:

Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: bees version v0.6-58-g4a1971b-dirty
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: 2019-01-03 18:22:08 3059.3059<7> bees: Masking signals
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: 2019-01-03 18:22:08 3059.3059<7> bees: BeesThread exec progress_report
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: 2019-01-03 18:22:08 3059.3059<7> bees: BeesThread exec status_report
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: 2019-01-03 18:22:08 3059.3059<6> bees: BeesStringFile .beeshome/beescrawl.dat max size 1M
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: 2019-01-03 18:22:08 3059.3059<7> bees: BeesThread exec crawl_transid
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: 2019-01-03 18:22:08 3059.3059<6> bees: Scan mode set to 0 (0)
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_transid[3062]: Calculating transid_max
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_transid[3062]: ---  END  TRACE --- exception ---
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_transid[3062]:
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_transid[3062]: *** EXCEPTION ***
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_transid[3062]:         exception type std::system_error: BTRFS_IOC_TREE_SEARCH_V2: rv = readlink(path.c_str(), buf, size + 1): No such file or directory at fs.cc:8>
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_transid[3062]: ***
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_261[3063]: Opening gentoo/rootfs/var/log/journal/5047221968d9d69177b931b50000000a/user-1000.journal found FS_NOCOW_FL flag in 0x800000
Jan 03 18:22:08 arbeitsplatz1 beesd[2814]: crawl_261[3065]: Opening gentoo/rootfs/var/log/journal/5047221968d9d69177b931b50000000a/system.journal found FS_NOCOW_FL flag in 0x800000

Note how it first prepends the timestamps and logs a different pid.tid format, then switches to --no-timestamps.

@Zygo
Copy link
Owner

Zygo commented Jan 3, 2019

That's probably my bad. I changed the startup order so the command-line option parser could invoke methods on BeesContext, but that means BeesContext's constructor now runs before we've parsed the --no-timestamps option, and BeesContext's constructor writes log messages.

The stuff in BeesContext that emits log messages should probably be moved to the ::start() method. In BeesContext's constructor there is no usable shared_this pointer which means it's too easy to accidentally trigger a deadlock or crash.

@kakra
Copy link
Contributor Author

kakra commented Sep 16, 2019

BTW: This also messes with bees --help...

kakra added a commit to kakra/bees that referenced this issue Nov 17, 2019
Do not touch BeesContext until really needed. As a safety, move its
initialization after cmdline parsing. Then follow the proven design of
adding the needed default value and apply it to BeesContext later.

Also, let's set a flag when initialization after cmdline parsing is done
so we know if we already want to log an exit code.

Fixes: commit 23f3e4e
Closes: Zygo#103
Signed-off-by: Kai Krakow <[email protected]>
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 a pull request may close this issue.

2 participants