[fix] cleanup server pid file on ungraceful shutdown in container
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
prefix_file="${API_PREFIX_FILE:-/app/data/api_prefix}"
|
prefix_file="${API_PREFIX_FILE:-/app/data/api_prefix}"
|
||||||
db_file="${RAILS_DB_PATH:-/app/data/rynDNS.sqlite3}"
|
db_file="${RAILS_DB_PATH:-/app/data/rynDNS.sqlite3}"
|
||||||
default_admin_file="${API_DEFAULT_KEY_FILE:-/app/data/api_default_admin}"
|
default_admin_file="${API_DEFAULT_KEY_FILE:-/app/data/api_default_admin}"
|
||||||
|
server_pid_file="${RAILS_PID_FILE:-/app/tmp/pids/server.pid}"
|
||||||
rails_bin="${RAILS_BINARY:-/app/bin/rails}"
|
rails_bin="${RAILS_BINARY:-/app/bin/rails}"
|
||||||
demo_cycle="${RAILS_DEMO_RESET:-60m}"
|
demo_cycle="${RAILS_DEMO_RESET:-60m}"
|
||||||
demo_prefix="zW3If4s5"
|
demo_prefix="zW3If4s5"
|
||||||
@@ -50,6 +51,15 @@ function random_sting()
|
|||||||
echo -n "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w "${1:-32}" | head -n 1)"
|
echo -n "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w "${1:-32}" | head -n 1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanup()
|
||||||
|
{
|
||||||
|
if [ -f $server_pid_file ]; then
|
||||||
|
log WAR cleanup last server shutdown may have not been graceful
|
||||||
|
log cleanup deleting old server pid file
|
||||||
|
rm $server_pid_file
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function get_prefix_file()
|
function get_prefix_file()
|
||||||
{
|
{
|
||||||
if [ -f "$prefix_file" ]; then
|
if [ -f "$prefix_file" ]; then
|
||||||
@@ -113,6 +123,7 @@ function db_setup()
|
|||||||
|
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
|
cleanup
|
||||||
set_api_prefix
|
set_api_prefix
|
||||||
log main prefix: $RAILS_API_KEY_PREFIX
|
log main prefix: $RAILS_API_KEY_PREFIX
|
||||||
db_setup
|
db_setup
|
||||||
@@ -122,4 +133,4 @@ function main()
|
|||||||
exec $rails_bin s
|
exec $rails_bin s
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user