Skip to content

Commit 6d67dee

Browse files
Logging inside all containers
1 parent 9665272 commit 6d67dee

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

sagemaker_ssh_helper/sm-helper-functions

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,15 @@ function _print_sm_studio_python() {
180180
echo -n "$SM_STUDIO_PYTHON"
181181
}
182182

183+
function _is_ssh_ide_inside_studio() {
184+
[[ -f /opt/ml/metadata/resource-metadata.json ]]
185+
}
186+
187+
183188
function _assert_is_ssh_ide_inside_studio() {
184-
if [[ ! -f /opt/ml/metadata/resource-metadata.json ]]; then
189+
if _is_ssh_ide_inside_studio; then
190+
: # all good
191+
else
185192
echo "sm-ssh-ide: ERROR: must be running inside SageMaker Studio"
186193
exit 2
187194
fi
@@ -198,7 +205,8 @@ function _locale_gen() {
198205

199206
function _start_syslogd() {
200207
if _is_centos; then
201-
/usr/sbin/rsyslogd
208+
nohup /usr/sbin/rsyslogd &
209+
nohup /usr/lib/systemd/systemd-journald &
202210
else
203211
service rsyslog start || (echo "ERROR: Failed to start syslogd service")
204212
fi

sagemaker_ssh_helper/sm-setup-ssh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ if [[ "$1" == "configure" ]]; then
4343
fi
4444

4545
# Sending all system logs to CloudWatch (helps to troubleshoot sshd issues)
46-
find /etc/rsyslog.conf /etc/rsyslog.d/ -type f \
47-
-exec sed -i -e 's~/var/log/~/var/log/apps/app_container.log__~' {} \;
46+
if _is_ssh_ide_inside_studio; then
47+
find /etc/rsyslog.conf /etc/rsyslog.d/ -type f \
48+
-exec sed -i -e 's~/var/log/~/var/log/apps/app_container.log__~' {} \;
49+
else
50+
find /etc/rsyslog.conf /etc/rsyslog.d/ -type f \
51+
-exec sed -i -e 's~/var/log/.*~/proc/1/fd/1~' {} \;
52+
# shellcheck disable=SC2016
53+
sed -i -e 's~^$PrivDropToUser~#$PrivDropToUser~' /etc/rsyslog.conf
54+
# shellcheck disable=SC2016
55+
sed -i -e 's~^$PrivDropToGroup~#$PrivDropToGroup~' /etc/rsyslog.conf
56+
fi
4857

4958
sed -i -e 's~^ClientAliveInterval~#ClientAliveInterval~' /etc/ssh/sshd_config
5059
echo "ClientAliveInterval 15" >> /etc/ssh/sshd_config

0 commit comments

Comments
 (0)