Created
November 26, 2024 23:30
-
-
Save scottschreckengaust/ac37fdecc691d87c85000c6ffe4a6f2f to your computer and use it in GitHub Desktop.
This gets the full command from PID 1 and checks for the process running
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# Get the process | |
FULL_COMMAND="$(sed -n l "/proc/1/cmdline" | sed -e 's/\\$//g' | tr -d '\n' | sed -e 's/\$$//g' | sed -e 's/\\000/ /g' | sed -e 's/ *$//g' | head -1)" | |
# Look for the process | |
pgrep --full "$FULL_COMMAND" 2> /dev/null > /dev/null; | |
exit ${?}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is "a way" to put in a generalized
HEALTHCHECK
within a Dockerfile: