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

No error logs/output if -ncwait option is passed and freeswitch fails before logging initialized #2751

Open
pbhenson opened this issue Jan 28, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@pbhenson
Copy link

Describe the bug

When freeswitch is started, switch.c calls daemonize which closes stderr in the child process. If -ncwait is passed, the parent creates a pipe before spawning the child and waits for the child to send it a 1 to indicate it started.

In between the call to daemonize and the write to the pipe by the child, various things could go wrong which cause it to just write to stderr and then exit, so the parent knows it failed, but not why.

Given stderr is dropped in the child, these errors are dumped into /dev/null and there’s no way to know what they were.

If the error is reproducible, you can start freeswitch in the foreground and see what it is. In my case, freeswitch is randomly failing to start at boot, and starting in foreground after boot works fine. But since the instance started at boot doesn't log why it failed anywhere, I can't figure out why it sometimes won't start.

To Reproduce

This is a contrived example of a static error in the config. Obviously you can just start in foreground and see what it is. But it demonstrates how when started in background there's no way to tell what failed:

Say for example /etc/freeswitch/freeswitch.xml doesn’t exist. freeswitch fails to start:

pbx-01 ~ # systemctl status freeswitch.service
× freeswitch.service - freeswitch
Loaded: loaded (/lib/systemd/system/freeswitch.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sat 2024-06-29 19:50:22 PDT; 30s ago
Duration: 52.239s
Process: 6000 ExecStart=/usr/bin/freeswitch -u ${USER} -g ${GROUP} -ncwait ${DAEMON_OPTS} (code=exited, s>
CPU: 44ms

Jun 29 19:50:22 pbx-01 systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
Jun 29 19:50:22 pbx-01 systemd[1]: Stopped freeswitch.service - freeswitch.
Jun 29 19:50:22 pbx-01 systemd[1]: freeswitch.service: Start request repeated too quickly.
Jun 29 19:50:22 pbx-01 systemd[1]: freeswitch.service: Failed with result ‘exit-code’.
Jun 29 19:50:22 pbx-01 systemd[1]: Failed to start freeswitch.service - freeswitch.

There’s nothing in the freeswitch log, the last entry is from being shut down before this test:

2024-06-29 19:50:06.562165 99.27% [NOTICE] switch_loadable_module.c:1573 Deleting Say interface ‘en’

There’s also nothing in the journal:

pbx-01 ~ # journalctl -xeu freeswitch.service

A start job for unit freeswitch.service has finished with a failure.

The job identifier is 3988 and the job result is failed.

Expected behavior

If freeswitch fails to start, any output to stderr should show up in systemd logs

Package version or git hash

freeswitch/experimental,now 1.10.12-release-10222002881-a88d069d6f~bookworm

@pbhenson pbhenson added the bug Something isn't working label Jan 28, 2025
@hdep
Copy link

hdep commented Jan 30, 2025

I got the same issue descrive in #2743. I can provide a coredumps of the issue. But for this I need a direct e-mail to send the file securely.

Thank you

@pbhenson
Copy link
Author

Hmm, I never have an issue starting once the box is up. It only fails during boot (probably a race condition of some kind, but without a log of what fails I dunno what). I don't think #2743 is necessarily the same as this as it appears in that case sometimes it freezes when started up manually.

@hdep
Copy link

hdep commented Jan 31, 2025

Ok thank you for your feedback I just reopen my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants