-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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,7 @@ | ||
# dora's to-do list | ||
|
||
A wish list for dora, currently without order of preference. | ||
|
||
- Set up global environment variable that contains the application directory | ||
(DRY). | ||
- Better in-container monitoring. |
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
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,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
# configure-msmtp.sh | ||
# This script is part of dora -- Docker container for Rails | ||
# https://github.com/bovender/dora | ||
|
||
|
||
echo "# dora configuring msmtp" | ||
MSMTPRC=/etc/msmtprc | ||
|
||
if [[ $(id -u) != 0 ]]; then | ||
echo "Script was invoked by user '$(id -u -n)'; re-invoking with sudo..." | ||
echo | ||
sudo $0 | ||
fi | ||
|
||
function show_help() { | ||
echo "Usage: $(basename $0) [options]" | ||
echo "Options:" | ||
echo " -f, --force: Force configuration even if $MSMTPRC exists" | ||
echo " -h, --help: Show this help" | ||
echo "This script creates $MSMTPRC with the content of the following variables:" | ||
echo " \$RAILS_SMTP_HOST=$RAILS_SMTP_HOST" | ||
echo " \$RAILS_SMTP_PORT=$RAILS_SMTP_PORT" | ||
echo " \$RAILS_SMTP_USER=$RAILS_SMTP_USER" | ||
echo " \$RAILS_SMTP_PASS=$RAILS_SMTP_PASS" | ||
echo " \$RAILS_SMTP_FROM=$RAILS_SMTP_FROM" | ||
} | ||
while [[ $1 != "" ]]; do | ||
case $1 in | ||
-h | --help ) | ||
show_help | ||
exit | ||
;; | ||
-f | --force ) | ||
FORCE=1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
if [[ $RAILS_SMTP_HOST == "" ]]; then | ||
echo "FATAL: environment variable \$RAILS_SMTP_HOST is empty!" | ||
exit 1 | ||
elif [[ -a $MSMTPRC && $FORCE != "1" ]]; then | ||
echo "FATAL: $MSMTPRC exists; use -f or --force to overwrite" | ||
exit 2 | ||
else | ||
[[ -a $MSMTPRC ]] && echo "WARNING: $MSMTPRC exists; forcing overwrite!" | ||
# Note that the heredoc lines must be preceded by true tabs | ||
cat <<-EOF | tee $MSMTPRC | ||
# msmtp configuration written by dora ($(basename $0)) on $(date -Is) | ||
account default | ||
host $RAILS_SMTP_HOST | ||
port $RAILS_SMTP_PORT | ||
user $RAILS_SMTP_USER | ||
from $RAILS_SMTP_FROM | ||
password $RAILS_SMTP_PASS | ||
tls_starttls | ||
EOF | ||
chown root:root $MSMTPRC | ||
chmod 0600 $MSMTPRC | ||
fi |
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
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
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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
# dora-status.sh | ||
# This script is part of dora -- Docker container for Rails | ||
# https://github.com/bovender/dora | ||
|
||
APP_DIR=/home/dora/rails | ||
LOG_TAIL_LINES=12 | ||
|
||
if [[ $GIT_PULL == "true" ]]; then | ||
GIT_DESCRIPTION=`git -C $APP_DIR describe 2>/dev/null` | ||
else | ||
GIT_DESCRIPTION="(not a Git repository)" | ||
fi | ||
|
||
echo -e "# dora status\n" | ||
echo "- Application mame: $APP_NAME" | ||
echo "- Repository version: $GIT_DESCRIPTION" | ||
echo "- Container uptime: `uptime`" | ||
|
||
echo -e "\n\n## nginx status\n" | ||
# TODO: need to e sudo? | ||
sv status nginx | ||
|
||
echo -e "\n\n## sidekiq status\n" | ||
sv status sidekiq | ||
|
||
echo -e "\n\n## Passenger status\n" | ||
passenger-status | ||
|
||
echo -e "\n\n## Log tails" | ||
for F in $APP_DIR/log/*.log; do | ||
echo -e "\n### ${F##*/}" | ||
echo "\`\`\`" | ||
tail -n $LOG_TAIL_LINES $F | ||
echo "\`\`\`" | ||
done | ||
|
||
echo -e "\n---" |
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
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
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,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# send-dora-status-mail.sh | ||
# This script is part of dora -- Docker container for Rails | ||
# https://github.com/bovender/dora | ||
|
||
TMP_FILE="/tmp/dora_mail_$(date -Ins).mbox" | ||
|
||
echo "# dora sending status mail" | ||
|
||
if [[ $RAILS_SMTP_FROM == "" ]]; then | ||
echo "FATAL: Cannot send status mail because \$RAILS_SMTP_FROM is empty." | ||
exit 1 | ||
elif [[ $EMAIL_REPORTS_TO == "" ]]; then | ||
echo "FATAL: Cannot send status mail because \$EMAIL_REPORTS_TO is empty." | ||
exit 2 | ||
else | ||
# Note that the heredoc lines must be preceded by tabs, not spaces! | ||
cat <<-EOF | msmtp $EMAIL_REPORTS_TO | ||
To: $EMAIL_REPORTS_TO | ||
Subject: [$APP_NAME] dora status report | ||
$(dora-status.sh) | ||
EOF | ||
fi |