unit: The $runstatedir is not being created at runtime
See the following configuration. I used a prefix of /opt/local/unit to make sure there were no previous existing directories or stuff that was left by a previous unit installation, and so that I can wipe it easily, but this could perfectly use system paths.
The issue is that the system is allowed (and will normally do so) to wipe /run (or /var/run) at [re]boot time. Since we use various files in /run (at least, the pid file and the control socket), the FHS says that we should use a directory within /run:
https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#runRuntimeVariableData
Programs may have a subdirectory of /run; this is encouraged for programs that use more than one run-time file.
alx@asus5775:~/src/nginx/unit$ ./configure --prefix=/opt/local/unit \
--modules=/opt/local/unit/lib/unit/modules \
--state=/opt/local/unit/var/lib/unit \
--pid=/opt/local/unit/var/run/unit/unit.pid \
--log=/opt/local/unit/var/log/unit/unit.log \
--control=unix:/opt/local/unit/var/run/unit/control.unit.sock \
| tail -n 27
Unit configuration summary:
bin directory: ............. "/opt/local/unit/bin"
sbin directory: ............ "/opt/local/unit/sbin"
lib directory: ............. "/opt/local/unit/lib"
include directory: ......... "/opt/local/unit/include"
man pages directory: ....... "/opt/local/unit/share/man"
modules directory: ......... "/opt/local/unit/lib/unit/modules"
state directory: ........... "/opt/local/unit/var/lib/unit"
tmp directory: ............. "/opt/local/unit/tmp"
pid file: .................. "/opt/local/unit/var/run/unit/unit.pid"
log file: .................. "/opt/local/unit/var/log/unit/unit.log"
control API socket: ........ "unix:/opt/local/unit/var/run/unit/control.unit.sock"
non-privileged user: ....... "nobody"
non-privileged group: ...... ""
IPv6 support: .............. YES
Unix domain sockets support: YES
TLS support: ............... NO
process isolation: ......... USER NS PID NET UTS CGROUP
debug logging: ............. NO
alx@asus5775:~/src/nginx/unit$ make -j >/dev/null; echo $?
0
alx@asus5775:~/src/nginx/unit$ sudo make install
install -d /opt/local/unit/sbin
install -p build/unitd /opt/local/unit/sbin/
install -d /opt/local/unit/var/lib/unit
install -d /opt/local/unit/share/man/man8
install -p -m644 build/unitd.8 /opt/local/unit/share/man/man8/
alx@asus5775:~/src/nginx/unit$ sudo /opt/local/unit/sbin/unitd
2022/08/05 20:12:22 [alert] 21613#21613 bind(6, unix:/opt/local/unit/var/run/unit/control.unit.sock.tmp) failed (2: No such file or directory)
unitd fails to create the socket (because it assumes the parent dir exists always), and exits.
unitd should create the parent directory previous to attempting to bind(2) the socket.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (16 by maintainers)
Commits related to this issue
- Socket: Ensured the control socket directory exists. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domain ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket directory exists. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domain ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket directory exists. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domain ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exists. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Ensured the control socket & pid file directories exist. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a ... — committed to ac000/unit by ac000 2 years ago
- Socket: Created control socket & pid file directories. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domai... — committed to ac000/unit by ac000 2 years ago
- Socket: Created control socket & pid file directories. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domai... — committed to ac000/unit by ac000 2 years ago
- Socket: Created control socket & pid file directories. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domai... — committed to ac000/unit by ac000 2 years ago
- Socket: Created control socket & pid file directories. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domai... — committed to ac000/unit by ac000 2 years ago
- Socket: Created control socket & pid file directories. @alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domai... — committed to nginx/unit by ac000 2 years ago
- Fs: Invert logic to reduce indentation Link: <https://github.com/nginx/unit/issues/742> Cc: Andrew Clayton <a.clayton@nginx.com> Cc: Liam Crilly <liam@nginx.com> Cc: Konstantin Pavlov <thresh@nginx.c... — committed to alejandro-colomar/unit by alejandro-colomar 2 months ago
- Fs: Correctly handle "/" in nxt_fs_mkdir_parent() The previous code attempted to mkdir(""), that is an empty string. Since "/" necessarily exists, just goto out_free. Link: <https://github.com/nginx... — committed to alejandro-colomar/unit by alejandro-colomar 2 months ago
- Fs: Make parents recursively in nxt_fs_mkdir_parent() Build systems should not attempt to create $runstatedir (or anything under it). Doing so causes warnings in packaging systems, such as in Alpine... — committed to alejandro-colomar/unit by alejandro-colomar 2 months ago
No, I think the code is fine as proposed in your patch. I just wanted to make sure that the obvious expected behavior was indeed occuring, which it is (per your ls(1) runs). So LGTM. 😃