Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and Features #55

Merged
merged 24 commits into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ebe7365
🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/52
apolopena Mar 7, 2021
f9b13db
👌 IMPROVE: add grc
apolopena Mar 7, 2021
f35e185
🐛 FIX: spinner and dynamic msg for waiting for server to start
apolopena Mar 7, 2021
18aaa30
👌 IMPROVE: grc colors for fix https://github.com/apolopena/gitpod-lar…
apolopena Mar 7, 2021
492f828
🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/54…
apolopena Mar 7, 2021
a76cb6f
🤖 TEST: force workspace image build
apolopena Mar 7, 2021
331f84e
👌 IMPROVE: log messages
apolopena Mar 7, 2021
4e4efd0
👌 IMPROVE: log message for git aliases
apolopena Mar 7, 2021
5dc5a3e
👌 IMPROVE: log messages
apolopena Mar 7, 2021
1e2994f
🐛 FIX: log message for writing rake tasks
apolopena Mar 7, 2021
7dd9a94
🐛 FIX: log messages
apolopena Mar 7, 2021
7ec6685
🤖 TEST: exit status
apolopena Mar 7, 2021
94d2591
🐛 FIX: write rake tasks flow
apolopena Mar 7, 2021
2669817
🐛 FIX: error codes
apolopena Mar 7, 2021
1a7e374
🐛 FIX: grc color config
apolopena Mar 7, 2021
4838586
🐛 FIX: linebreak in log msg
apolopena Mar 7, 2021
2949e24
👌 IMPROVE: log messages
apolopena Mar 7, 2021
b5d9502
👌 IMPROVE: log message for git aliases
apolopena Mar 7, 2021
24c7374
🐛 FIX: allow stop_apache to kill grc tail
apolopena Mar 7, 2021
f9f1ef2
🐛 FIX: kill tail and multitail
apolopena Mar 7, 2021
2f96b00
🐛 FIX: order of grep string for getting tail pid
apolopena Mar 7, 2021
ae25c79
🐛 FIX: typos
apolopena Mar 7, 2021
6127930
🤖 TEST: force worksapce image build
apolopena Mar 7, 2021
f662649
🤖 TEST: multitail
apolopena Mar 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ RUN sudo touch /var/log/apache2/other_vhosts_access.log \
&& sudo chmod 666 /var/log/apache2/other_vhosts_access.log

RUN sudo apt-get update -q \
&& sudo apt-get install -y rsync
&& sudo apt-get install -y rsync \
&& sudo apt-get install -y grc

RUN wget http://xdebug.org/files/xdebug-3.0.2.tgz \
&& tar -xvzf xdebug-3.0.2.tgz \
Expand All @@ -41,7 +42,7 @@ RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh

# gitpod trick to bypass the docker caching mechanism for all lines below this one
# just increment the value each time you want to bypass the cache system
ENV INVALIDATE_CACHE=123
ENV INVALIDATE_CACHE=125

COPY --chown=gitpod:gitpod bash/utils.sh /tmp
COPY --chown=gitpod:gitpod starter.ini /tmp
Expand Down
7 changes: 5 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ tasks:
if [ $(bash bash/helpers.sh is_inited) == 1 ]; then \
gp sync-done gitpod-inited
fi;
. bash/third-party/spinner.sh
UP=$(pgrep mysql | wc -l); \
if [ "$UP" -ne 1 ]; then \
. bash/third-party/spinner.sh &&
start_spinner "Initializing MySql..." &&
gp await-port 3306 &&
stop_spinner $?; \
fi &&
gp await-port 3306 &&
sleep 1 &&
__server=$(bash bash/utils.sh parse_ini_value starter.ini development default_server); \
start_spinner "Starting $__server web server when system is ready..." &&
gp sync-await gitpod-inited &&
stop_spinner $? &&
bash -i bash/helpers.sh start_server
name: Web Server
- openMode: split-top
Expand Down
35 changes: 28 additions & 7 deletions bash/before-tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,38 @@ log_silent () {

# Rake tasks (will be written to ~/.rake).
# Some rake tasks are dynamic and depend on the configuration in starter.ini
msg="Writing rake tasks"
log "$msg" &&
bash bash/init-rake-tasks.sh
if [ "$(bash bash/utils.sh parse_ini_value starter.ini github-changelog-generator install)" ]; then
msg="Writing rake tasks"
log "$msg..." &&
bash bash/init-rake-tasks.sh
if [ $? == 0 ]; then
log "SUCCESS: $msg"
else
log "ERROR: $msg" -e
fi
fi


# Aliases for git
msg="Writing git aliases"
log "$msg" &&
msg="\ngit aliases have been written"
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/emoji-log ~/.gitconfig &&
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/git-aliases ~/.gitconfig
log "try: git a or: git aliases for a list your git aliases.\n"
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/git-aliases ~/.gitconfig &&
log "$msg" &&
log "\ntry: git a or: git aliases\nto see what is available.\n"

# grc color configuration for apache logs
msg="Creating grc color configuration file for apache logs: ~/apache-log-colors.conf"
log "$msg..." &&
cat bash/snippets/grc/apache-log-colors > ~/apache-log-colors.conf
if [ $? == 0 ]; then
log "SUCCESS: $msg"
else
log "ERROR: $msg" -e
fi

# Keep this at the bottom of the file
# Restores files marked as persistant
# See persist_file in bash/helpers.sh
if [ $(bash bash/helpers.sh is_inited) == 1 ]; then
bash bash/helpers.sh restore_persistent_files $GITPOD_REPO_ROOT
fi
10 changes: 5 additions & 5 deletions bash/init-gitpod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ stop_spinner $?

# Move Laravel project files if they are not already in version control
if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
msg="\nMoving Laravel project from ~/temp-app to $GITPOD_REPO_ROOT using rsync"
msg="\nrsync Laravel project from ~/temp-app to $GITPOD_REPO_ROOT"
# TODO: replace spinner with a real progress bar for coreutils
log_silent "$msg" && start_spinner "$msg"
log_silent "$msg..." && start_spinner "$msg..."
shopt -s dotglob
rsync -rlptgoD --ignore-existing ~/test-app/ $GITPOD_REPO_ROOT
err_code=$?
if [ $err_code != 0 ]; then
stop_spinner $err_code
log "ERROR: Failed to move Laravel project from ~/temp-app to $GITPOD_REPO_ROOT using rsync" -e
log "ERROR: Failed to rsync Laravel project from ~/temp-app to $GITPOD_REPO_ROOT" -e
else
stop_spinner $err_code
log "SUCCESS: moved Laravel project from ~/temp-app to $GITPOD_REPO_ROOT using rsync"
log "SUCCESS: rsync Laravel project from ~/temp-app to $GITPOD_REPO_ROOT"
fi

# BEGIN: parse configurations
Expand Down Expand Up @@ -71,7 +71,7 @@ if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
__laravel_db_exists=$(mysqlshow 2>/dev/null | grep laravel >/dev/null 2>&1 && echo "1" || echo "0")
if [ $__laravel_db_exists == 0 ]; then
__laravel_db_msg="laravel database did not exist in mysql. Creating database: laravel"
log_silent "$__laravel_db_msg" && start_spinner "$__laravel_db_msg"
log_silent "$__laravel_db_msg..." && start_spinner "$__laravel_db_msg..."
mysql -e "CREATE DATABASE laravel;"
err_code=$?
if [ $err_code != 0 ]; then
Expand Down
10 changes: 5 additions & 5 deletions bash/init-rake-tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ EOF
}
# END: dynamic rake task functions

# BEGIN: conditionally add dynamic rake tasks
if [ "$(eval $parse github-changelog-generator install)" ]; then
# BEGIN: add rake tasks
add_changelog_rake
[ $? != 0 ] && exit 1
fi
# END: conditionally add dynamic rake tasks
if [ $? != 0 ]; then
exit 1
fi
# END: add rake tasks



Expand Down
41 changes: 41 additions & 0 deletions bash/snippets/grc/apache-log-colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# grc config file for apache log colors

# ip number
regexp=^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
colours=bold magenta
count=once
-
# everything in brackets
regexp=\[.+?\]
colours=cyan
count=once
-
# everything in ""
regexp=\".+?\"
colours=blue
count=more
-
# HTTP Method
regexp=(?:HEAD|GET|POST|PUT|DELETE)
colours=bold blue
count=once
-
# HTTP Path
regexp=\s/[^\s]+
colours=bold green
count=once
-
# HTTP OK Status codes
regexp=\s(?:10[01]|20[02467]|30[0123457])
colours=green
count=once
-
# HTTP Error status code
regexp=\s(?:40[1-9]|41[1-8]|42[2-9]|431|444|450|50[2-9]|599)
colours=bold red
count=once
-
# Request byte size
regexp=\s(?!(?:10[01]|20[02467]|30[0123457])|(?:40[1-9]|41[1-8]|42[2-9]|431|444|450|50[2-9]|599))\d+
colours=yellow
count=once
38 changes: 34 additions & 4 deletions bash/snippets/server-functions
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
mtail_apache () {
mtail_apache() {
multitail /var/log/apache2/access.log -I /var/log/apache2/error.log;
}

tail_apache() {
# See bash/before-tasks.sh for setup of ~/apache-log-colors.conf
grc -c /home/gitpod/apache-log-colors.conf tail -f /var/log/apache2/access.log /var/log/apache2/error.log
}

start_apache() {
apachectl start
(( $? == 0 )) || return
mtail_apache
local log_monitor_type="$(bash \
$GITPOD_REPO_ROOT/bash/utils.sh parse_ini_value starter.ini development apache_log_monitor)"
case "$log_monitor_type" in
'tail')
tail_apache
;;
'multitail')
mtail_apache
;;
*)
echo "ERROR start_apache: invalid apache_log_monitor type: $log_monitor_type. Check your starter.ini"
;;
esac
}

stop_apache() {
apachectl stop
(( $? == 0 )) || return
local pid
# The grep string here must match the command given in the function start_apache
pid=$(ps axf | grep 'multitail /var/log/apache2/access.log -I /var/log/apache2/error.log' | grep -v grep | awk '{print $1}' | sed 1q)
local log_monitor_type="$(bash \
$GITPOD_REPO_ROOT/bash/utils.sh parse_ini_value starter.ini development apache_log_monitor)"
case "$log_monitor_type" in
'tail')
# The grep string here must match the tail portion of the command given in the function start_apache
pid=$(ps axf | grep 'tail -f /var/log/apache2/access.log /var/log/apache2/error.log' | grep -v grep | awk '{print $1}' | sed 1q)
;;
'multitail')
# The grep string here must match the command given in the function start_apache
pid=$(ps axf | grep 'multitail /var/log/apache2/access.log -I /var/log/apache2/error.log' | grep -v grep | awk '{print $1}' | sed 1q)
;;
*)
echo "ERROR start_apache: invalid apache_log_monitor type: $log_monitor_type. Check your starter.ini"
;;
esac
kill -2 $pid
}

Expand Down
2 changes: 2 additions & 0 deletions starter.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[development]
# Valid values: apache, php
default_server=apache
# Valid values are tail (uses grc) and multitail
apache_log_monitor=multitail

[.editorconfig]
# valid values are:
Expand Down