Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 5124ae5

Browse files
author
Alex Paliarush
committed
- Improved error reporting #112
- Cache warm up is made optional (using -w flag) - Fixed m-clear-cache for Magento production mode
1 parent 32615e0 commit 5124ae5

12 files changed

+72
-19
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2525

2626
### Added
2727

28+
- Added generation of basic sample data for testing purposes
29+
- Ability to upgrade Magento using `m-switch-to-ce` and `m-switch-to-ee` (when `-u` flag is specified)
2830
- Redis support for Magento caching
2931
- Access to Magento developer mode and storefront/admin UI debugging features via [etc/config.yaml.dist](etc/config.yaml.dist)
3032
- Composer-based installation support
31-
- Magento cache warming up after re-install and clearing cache
33+
- Magento cache warming up after re-install and clearing cache (when `-w` flag is specified)
3234
- Tests configuration files are generated during project initialization
3335
- Sample data support
3436
- ElasticSearch support

init_project.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -240,4 +242,4 @@ if [[ ${host_os} == "Windows" ]] || [[ ${use_nfs} == 0 ]]; then
240242
If not using PhpStorm, you can set up synchronization using rsync"
241243
fi
242244

243-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set debug:vagrant_project to 1 in config.yaml"
245+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set debug:vagrant_project to 1 in config.yaml"

m-bin-magento

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -18,4 +20,4 @@ vagrant ssh -c "\$MAGENTO_ROOT/bin/magento $arguments" 2> >(logError)
1820
# To debug, comment out line above and uncomment line below
1921
# vagrant ssh -c "php -d xdebug.remote_autostart=1 \$MAGENTO_ROOT/bin/magento $arguments" 2> >(logError)
2022

21-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
23+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-clear-cache

+18-6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,31 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

12+
warm_up_cache=0
13+
while getopts 'w' flag; do
14+
case "${flag}" in
15+
w) warm_up_cache=1 ;;
16+
*) error "Unexpected option" && exit 1;;
17+
esac
18+
done
19+
1020
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
1121
if [[ ${debug_vagrant_project} -eq 1 ]]; then
1222
set -x
1323
fi
1424

1525
bash "${vagrant_dir}/scripts/host/m_clear_cache.sh" "$@" 2> >(logError)
1626

17-
incrementNestingLevel
18-
19-
bash "${vagrant_dir}/scripts/host/warm_up_cache.sh" 2> >(logError)
20-
21-
decrementNestingLevel
27+
if [[ ${warm_up_cache} -eq 1 ]]; then
28+
incrementNestingLevel
29+
bash "${vagrant_dir}/scripts/host/warm_up_cache.sh" 2> >(logError)
30+
decrementNestingLevel
31+
else
32+
info "Use 'bash ./m-clear-cache -w' to get automatic cache warm up"
33+
fi
2234

23-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
35+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-composer

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -14,4 +16,4 @@ fi
1416

1517
bash "${vagrant_dir}/scripts/host/m_composer.sh" "$@" 2> >(logError)
1618

17-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
19+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-reinstall

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -14,4 +16,4 @@ fi
1416

1517
bash "${vagrant_dir}/scripts/host/m_reinstall.sh" "$@" 2> >(logError)
1618

17-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
19+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-search-engine

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -15,4 +17,4 @@ fi
1517
cd "${vagrant_dir}"
1618
vagrant ssh -c "bash /vagrant/scripts/guest/m-search-engine ${@}" 2> >(logError)
1719

18-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
20+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-switch-to-ce

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -14,4 +16,4 @@ fi
1416

1517
bash "${vagrant_dir}/scripts/host/m_switch_to_ce.sh" "$@" 2> >(logError)
1618

17-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
19+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-switch-to-ee

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -14,4 +16,4 @@ fi
1416

1517
bash "${vagrant_dir}/scripts/host/m_switch_to_ee.sh" "$@" 2> >(logError)
1618

17-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
19+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

m-varnish

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD
66

77
source "${vagrant_dir}/scripts/output_functions.sh"
8+
current_script_name=`basename "$0"`
9+
log_file="${vagrant_dir}/log/${current_script_name}.log"
810
resetNestingLevel
911

1012
debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
@@ -15,4 +17,4 @@ fi
1517
cd "${vagrant_dir}"
1618
vagrant ssh -c "bash /vagrant/scripts/guest/m-varnish ${@}" 2> >(logError)
1719

18-
info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
20+
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"

scripts/guest/m-clear-cache

+14-2
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,33 @@ incrementNestingLevel
99

1010
status "Clearing directories containing temporary files"
1111

12+
mage_mode=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "magento_mode")
13+
1214
rm -f "${MAGENTO_ROOT}/app/etc/paths.php"
1315
if [[ -d "${MAGENTO_ROOT}/var" ]]; then
1416
#clear var
15-
cd "${MAGENTO_ROOT}" && mv var/.htaccess var_htaccess.back && rm -rf var/* var/.[^.]*
17+
cd "${MAGENTO_ROOT}"
18+
mv var/.htaccess var_htaccess.back
19+
if [[ -d "${MAGENTO_ROOT}/var/generation" ]] && [[ ${mage_mode} == "production" ]]; then
20+
mv var/generation var_generation.back
21+
fi
22+
rm -rf var/* var/.[^.]*
1623
if [[ -f var_htaccess.back ]]; then
1724
mv var_htaccess.back var/.htaccess
1825
fi
26+
if [[ -d "${MAGENTO_ROOT}/var_generation.back" ]] && [[ ${mage_mode} == "production" ]]; then
27+
mv var_generation.back var/generation
28+
fi
1929
fi
20-
if [[ -d "${MAGENTO_ROOT}/pub" ]]; then
30+
31+
if [[ -d "${MAGENTO_ROOT}/pub" ]] && [[ ${mage_mode} != "production" ]]; then
2132
#clear pub/statics
2233
cd "${MAGENTO_ROOT}/pub" && mv static/.htaccess static_htaccess.back && rm -rf static && mkdir static
2334
if [[ -f static_htaccess.back ]]; then
2435
mv static_htaccess.back static/.htaccess
2536
fi
2637
fi
38+
2739
if [[ -d "${MAGENTO_ROOT}/dev" ]]; then
2840
#clear integration tests tmp
2941
cd "${MAGENTO_ROOT}/dev/tests/integration" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp

scripts/output_functions.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.." && vagrant_dir=$PWD
44

55
source "${vagrant_dir}/scripts/colors.sh"
66

7-
log_file="${vagrant_dir}/log/debug.log"
7+
default_log="${vagrant_dir}/log/debug.log"
8+
log_file_path="${vagrant_dir}/scripts/.current_log_path"
89
nesting_level_file="${vagrant_dir}/scripts/.current_nesting_level"
910

1011
function info() {
@@ -53,6 +54,11 @@ function log() {
5354
input="$(cat)"
5455
fi
5556
if [[ -n "${input}" ]]; then
57+
if [[ -f "${log_file_path}" ]]; then
58+
log_file="${vagrant_dir}/$(cat "${log_file_path}")"
59+
else
60+
log_file="${default_log}"
61+
fi
5662
echo "${input}" | sed "s/\[[[:digit:]]\{1,\}m//g" >> "${log_file}"
5763
fi
5864
}
@@ -131,7 +137,12 @@ function decrementNestingLevel()
131137
function resetNestingLevel()
132138
{
133139
rm -f "${nesting_level_file}"
134-
rm -f "${log_file}"
140+
if [[ -f "${log_file_path}" ]]; then
141+
log_file="${vagrant_dir}/$(cat "${log_file_path}")"
142+
rm -f "${log_file_path}"
143+
rm -f "${log_file}"
144+
fi
145+
rm -f "${default_log}"
135146
}
136147

137148
function getIndentationByNesting()

0 commit comments

Comments
 (0)