From 973acace81b0efb8faf233a6cf0952ecd8958fe3 Mon Sep 17 00:00:00 2001 From: Dave Kleinschmidt Date: Tue, 6 Aug 2024 14:08:29 -0400 Subject: [PATCH] Ensure pid directory exists (#11) --- Project.toml | 2 +- src/graceful_termination.jl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 39605da..15b58b3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "K8sDeputy" uuid = "2481ae95-212f-4650-bb21-d53ea3caf09f" authors = ["Beacon Biosignals, Inc"] -version = "0.1.2" +version = "0.1.3" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/graceful_termination.jl b/src/graceful_termination.jl index be6d49b..b15b116 100644 --- a/src/graceful_termination.jl +++ b/src/graceful_termination.jl @@ -21,7 +21,11 @@ end # Following the Linux convention for pid files: # https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html entrypoint_pid_file() = joinpath(_deputy_ipc_dir(), "julia-entrypoint.pid") -set_entrypoint_pid(pid::Integer) = write(entrypoint_pid_file(), string(pid) * "\n") +function set_entrypoint_pid(pid::Integer) + file = entrypoint_pid_file() + mkpath(dirname(file)) + return write(file, string(pid) * "\n") +end function entrypoint_pid() pid_file = entrypoint_pid_file()