Skip to content

Conversation

@MemoryLeak55
Copy link

I added the ability to the cli to set pid files, useful for systemd units. I added the ability to set a working dir, and updated daemonize and tracing to the latest versions. Logging to files now work in daemon mode, as well as no complaints from epoll about being interrupted

.open(log)
.unwrap_or_else(move |_| panic!("Could not create log file {}", &log));

let (non_blocking, _guard) = tracing_appender::non_blocking(log_file);
Copy link

Choose a reason for hiding this comment

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

The _guard and thus log file will be dropped at the end of this branch. The _guard must be held at the top level in order for the log to keep working, i.e.

fn main() {
    ...
    let _guard;
    ...

                let (non_blocking, guard) = tracing_appender::non_blocking(log_file);
                _guard = guard;

    ...

this is basically the approach in the main branch

let _guard;
if background {
let log = matches.value_of("log").unwrap();
let log_file =
File::create(log).unwrap_or_else(|_| panic!("Could not create log file {}", log));
let (non_blocking, guard) = tracing_appender::non_blocking(log_file);
_guard = guard;

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.

2 participants