From 57fc9201cb91e3d8901a64e3daaaf31684ee5bf5 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Sun, 7 Aug 2022 00:19:24 +0100 Subject: 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 Domain Socket) 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) This could happen if the control socket was set to a directory that doesn't exist. A common place to put the control socket would be under /run/unit, and while /run will exist, /run/unit may well not (/run is/should be cleared on each boot). The pid file would also generally go under /run/unit, though this is created after the control socket, however it could go someplace else so we should also ensure its directory exists. This commit will try to create the pid file and control sockets parent directory. In some cases the user will need to ensure that the rest of the path already exists. This adds a new nxt_fs_mkdir_parent() function that given a full path to a file (or directory), strips the last component off before passing the remaining directory path to nxt_fs_mkdir(). Cc: Konstantin Pavlov Closes: Reported-by: Alejandro Colomar Reviewed-by: Alejandro Colomar Tested-by: Alejandro Colomar Signed-off-by: Andrew Clayton --- src/nxt_fs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nxt_fs.h') diff --git a/src/nxt_fs.h b/src/nxt_fs.h index ff589979..af9585b8 100644 --- a/src/nxt_fs.h +++ b/src/nxt_fs.h @@ -36,6 +36,7 @@ typedef struct { } nxt_fs_mount_t; +nxt_int_t nxt_fs_mkdir_parent(const u_char *path, mode_t mode); nxt_int_t nxt_fs_mkdir_all(const u_char *dir, mode_t mode); nxt_int_t nxt_fs_mount(nxt_task_t *task, nxt_fs_mount_t *mnt); void nxt_fs_unmount(const u_char *path); -- cgit