-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cron invocation, enable rotation for API and Sentinel
Toward medic/cht-core#4620.
- Loading branch information
David Brown
committed
Jun 20, 2018
1 parent
5d2c42d
commit 308858d
Showing
11 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
platform/packages/medic-api/scripts/medic-api/include/link-logs
This file contains 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
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
20
platform/packages/medic-api/scripts/medic-api/include/logrotate
This file contains 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
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
19
platform/packages/medic-api/scripts/medic-api/setup/link-logs
This file contains 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
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
19
platform/packages/medic-api/scripts/medic-api/setup/logrotate
This file contains 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
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 "$?" | ||
|
4 changes: 4 additions & 0 deletions
4
platform/packages/medic-api/settings/medic-api/logrotate/medic-api.conf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
/srv/storage/medic-api/logs/*.log { | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
platform/packages/medic-sentinel/scripts/medic-sentinel/include/link-logs
This file contains 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
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
20
platform/packages/medic-sentinel/scripts/medic-sentinel/include/logrotate
This file contains 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
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
19
platform/packages/medic-sentinel/scripts/medic-sentinel/setup/link-logs
This file contains 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
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
19
platform/packages/medic-sentinel/scripts/medic-sentinel/setup/logrotate
This file contains 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
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 "$?" | ||
|
4 changes: 4 additions & 0 deletions
4
platform/packages/medic-sentinel/settings/medic-sentinel/logrotate/medic-sentinel.conf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
/srv/storage/medic-sentinel/logs/*.log { | ||
} | ||
|
This file contains 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