Skip to content

Commit

Permalink
Fix cron invocation, enable rotation for API and Sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
David Brown committed Jun 20, 2018
1 parent 5d2c42d commit 308858d
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 6 deletions.
10 changes: 10 additions & 0 deletions platform/packages/medic-api/scripts/medic-api/include/link-logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

link_logs()
{
rm -f "/var/log/$PACKAGE_NAME" &&
ln -sf "$PACKAGE_STORAGE/logs" "/var/log/$PACKAGE_NAME"

return "$?"
}

20 changes: 20 additions & 0 deletions platform/packages/medic-api/scripts/medic-api/include/logrotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

logrotate_install()
{
local logrotate_dir='/etc/logrotate.d'
local logrotate_cfg="$PACKAGE_NAME.conf"
local logrotate_dst_path="$logrotate_dir/$logrotate_cfg"
local logrotate_src_path="$PACKAGE_SETTINGS/logrotate/$logrotate_cfg"

mkdir -p "$logrotate_dir" \
|| return 1

if ! [ -f "$logrotate_dst_path" ]; then
ln -sf "$logrotate_src_path" "$logrotate_dst_path" \
|| return 2
fi

return 0
}

19 changes: 19 additions & 0 deletions platform/packages/medic-api/scripts/medic-api/setup/link-logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

main()
{
local self="`realpath "$0"`"
local base="`dirname -- "$self"`"

source "$base/../env" &&
merge_environment /srv || return 255

source "$base/../include/link-logs" &&
link_logs

return "$?"
}

main "$@"
exit "$?"

19 changes: 19 additions & 0 deletions platform/packages/medic-api/scripts/medic-api/setup/logrotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

main()
{
local self="`realpath "$0"`"
local base="`dirname -- "$self"`"

source "$base/../env" &&
merge_environment /srv || return 255

source "$base/../include/logrotate" && logrotate_install \
|| return 1

return 0
}

main "$@"
exit "$?"

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

/srv/storage/medic-api/logs/*.log {
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

link_logs()
{
rm -f "/var/log/$PACKAGE_NAME" &&
ln -sf "$PACKAGE_STORAGE/logs" "/var/log/$PACKAGE_NAME"

return "$?"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

logrotate_install()
{
local logrotate_dir='/etc/logrotate.d'
local logrotate_cfg="$PACKAGE_NAME.conf"
local logrotate_dst_path="$logrotate_dir/$logrotate_cfg"
local logrotate_src_path="$PACKAGE_SETTINGS/logrotate/$logrotate_cfg"

mkdir -p "$logrotate_dir" \
|| return 1

if ! [ -f "$logrotate_dst_path" ]; then
ln -sf "$logrotate_src_path" "$logrotate_dst_path" \
|| return 2
fi

return 0
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

main()
{
local self="`realpath "$0"`"
local base="`dirname -- "$self"`"

source "$base/../env" &&
merge_environment /srv || return 255

source "$base/../include/link-logs" &&
link_logs

return "$?"
}

main "$@"
exit "$?"

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

main()
{
local self="`realpath "$0"`"
local base="`dirname -- "$self"`"

source "$base/../env" &&
merge_environment /srv || return 255

source "$base/../include/logrotate" && logrotate_install \
|| return 1

return 0
}

main "$@"
exit "$?"

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

/srv/storage/medic-sentinel/logs/*.log {
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

start()
{
local logs_dir='/srv/storage/system-services/logs'

mkdir -p "$logs_dir" &&
\
exec /boot/timestamp \
busybox crond -f -L "$log_path" \
>> "$logs_dir/cron.log" 2>&1
cron -f >> "$logs_dir/cron.log" 2>&1
}

main()
Expand Down

0 comments on commit 308858d

Please sign in to comment.