Skip to content

Commit 0d4bfa9

Browse files
committed
Add script to patch DigitalOcean for journal
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 120a34c commit 0d4bfa9

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

cmd/install.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ Check the status of the faasd service with:
9393
sudo journalctl -u faasd --lines 100 -f
9494
9595
Login with:
96-
sudo -E cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s
97-
`)
96+
sudo -E cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s`)
97+
98+
fmt.Println("")
9899

99100
return nil
100101
}

hack/enable-journal.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Copyright OpenFaaS Ltd 2025
4+
5+
# This script is for use with Droplets created on DigitalOcean, it will
6+
# ensure that systemd-journald is configured to log to disk and that
7+
# rsyslog is configured to read from systemd-journald.
8+
9+
# Without this change, no logs will be available in the journal, and only
10+
# /var/log/syslog will be populated.
11+
12+
set -e
13+
14+
echo "Checking systemd-journald logs..."
15+
JOURNAL_STATUS=$(journalctl --no-pager -n 10 2>&1)
16+
17+
if echo "$JOURNAL_STATUS" | grep -q "No journal files were found"; then
18+
echo "No journal files found. Fixing logging configuration..."
19+
else
20+
echo "Journald appears to be logging. No changes needed."
21+
exit 0
22+
fi
23+
24+
# Backup original config before making changes
25+
sudo cp /etc/systemd/journald.conf /etc/systemd/journald.conf.bak
26+
27+
# Ensure Storage is persistent
28+
sudo sed -i '/^#Storage=/c\Storage=persistent' /etc/systemd/journald.conf
29+
30+
# Ensure logs are not forwarded only to syslog
31+
sudo sed -i '/^#ForwardToSyslog=/c\ForwardToSyslog=no' /etc/systemd/journald.conf
32+
33+
# Restart systemd-journald
34+
echo "Restarting systemd-journald..."
35+
sudo systemctl restart systemd-journald
36+
37+
# Check if rsyslog already loads imjournal
38+
if ! grep -q 'module(load="imjournal")' /etc/rsyslog.conf; then
39+
echo "Adding imjournal module to rsyslog..."
40+
echo 'module(load="imjournal" StateFile="/var/lib/rsyslog/imjournal.state")' | sudo tee -a /etc/rsyslog.conf
41+
fi
42+
43+
# Restart rsyslog to apply changes
44+
echo "Restarting rsyslog..."
45+
sudo systemctl restart rsyslog
46+
47+
echo "Done. Checking if logs appear in journald..."
48+
journalctl --no-pager -n 10

0 commit comments

Comments
 (0)