-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev
executable file
·116 lines (98 loc) · 3.44 KB
/
dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#
# ./dev clear everything (except the database), run migrations and start a server, ready for realtime changes.
# ./dev fresh same as above but also with a fresh database (will purge all data)
# ./dev tinker just open a fresh tinker with all env variables loaded.
#
clear
echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
echo '% %% %%%%%%%% %%%% %%% *%%%% %%%%%% %%% %%% %%% %%%%%%% %%%%% %%%%%%%'
echo '% %% %%%%%%% %%%%%%%%%% %%%%%%%%%%% %%%%% %%%% %%%%%% %%% %%%%%% %%%%%% %%%%%% %%%%%% %%% %%%%%% %%%% %%%%%%%'
echo '%%% %% %%%%%%% %%%%%%%# %%%%%%%%%%% %%%%% %%%% %%%%%% %%% %%%%%%% %%%%%% %%%%%%% %%% %%%%%%%% %%% %%%%%%%'
echo '% %%% %%%%%%%%%%%%% %%%# %%%%%%%%%%% %%%%%% %%%%%% %%% %%%%%% %%%%%% %%%%%% %%%%%%% %%% %%%%%%%% %%% %%%%%%%'
echo '% %%% %%%%%%%%%%%%%% %%% %%%%%%%%%%% %%%% %%%%% %%%%%% %%% %%%%%% %%%%%% %%%%%% %%%%%%% %%%% %%%%%% %%%% %%%%%%%'
echo '% %% %%%%%%% %%%%% %%%% %%%%% %%%%% *%%%% %%%%%%% %%%%%%% %%%%%%% %%%%% %'
echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
if [ -z "$(which php73)" ]
then
php=$(which php)
else
php=$(which php73)
fi
$php --version
dir=$(pwd)
queue="artisan queue:listen --queue=analyze,run,notify,build,delete --timeout=0 -vv"
npm="npm run development -- --watch --display errors-only"
serve="artisan serve --port=1234 -vv"
PrevCI=$CI
function killqueue() {
ps ax | grep "artisan queue:listen" | awk -F ' ' '{print $1}' | xargs kill -2 >/dev/null 2>&1
}
function killnpm() {
ps ax | grep "$npm" | awk -F ' ' '{print $1}' | xargs kill -2 >/dev/null 2>&1
}
function killserve() {
ps ax | grep "$serve" | awk -F ' ' '{print $1}' | xargs kill -2 >/dev/null 2>&1
}
function ctrl_c() {
echo ; echo "Terminating (expect an exception)."
killqueue
killnpm
export CI=$PrevCI
exit 0
}
mkdir -p ./storage/framework/cache/data
if [ "$1" == "tinker" ]; then
echo "Prepping Tinker"
$php artisan config:clear -v
$php artisan cache:clear -v
$php artisan tinker
exit;
fi
# Start trapping Ctrl-C to terminate everything we start here.
trap ctrl_c INT
echo ; echo "Starting asset compilation."
export CI=true
killnpm
npm run watch &
echo ; echo "Cleaninng private folder to preserve space."
rm -rf ./storage/app/private
if [ -z "$(which composer)" ]
then
echo "Could not find composer"
exit 1;
else
echo ; echo "Running composer install."
$php -n "$(which composer)" install
fi
echo ; echo "Clearing/optimizing cache."
$php artisan optimize -v
$php artisan cache:clear -v
$php artisan route:cache -v
$php artisan view:cache -v
$php artisan config:cache -v
if [ "$1" == "fresh" ]; then
echo ; echo "Building fresh database."
$php artisan migrate:fresh --seed -v
else
echo ; echo "Running any new migrations."
$php artisan migrate -v
fi
echo ; echo "Starting queue processor."
killqueue
$php $queue &
while true
do
echo ; echo "Starting server."
$php $dir/$serve
echo "Terminated: $?"
if [[ "$?" == "130" ]]
then
ctrl_c
else
if [[ "$?" == "1" ]]
then
sleep 5
fi
fi
done