1#!/bin/sh
2
3export CHROME_BIN=/usr/bin/chromium
4export DUSK_WEBDRIVER_BIN=/usr/bin/chromedriver
5
6command=octane
7if [ "$#" -gt 0 ]; then
8 command="$1"
9 shift
10fi
11
12# commands
13_job() {
14 exec ./artisan queue:listen --queue=notification,default,beatmap_high,beatmap_default,store-notifications --tries=3 --timeout=1000
15}
16
17_migrate() {
18 ./artisan db:create
19 exec ./artisan migrate:fresh-or-run
20}
21
22_octane() {
23 echo_counter=0
24 manifest_path='./public/assets/manifest.json'
25 while [ ! -f "$manifest_path" ]; do
26 if [ "$echo_counter" -le 0 ]; then
27 echo_counter=5
28 echo "waiting to start octane: ${manifest_path##*/} not found" >&2
29 fi
30
31 : $(( echo_counter -= 1 ))
32 sleep 1
33 done
34
35 exec ./artisan octane:start --host=0.0.0.0 "$@"
36}
37
38_schedule() {
39 exec ./artisan schedule:work
40}
41
42_test() {
43 command=phpunit
44 if [ "$#" -gt 0 ]; then
45 command="$1"
46 shift
47 fi
48
49 case "$command" in
50 browser) _test_browser "$@";;
51 js) exec yarn karma start --single-run --browsers ChromeHeadless "$@";;
52 phpunit) exec ./bin/phpunit.sh "$@";;
53 esac
54}
55
56_test_browser() {
57 export APP_ENV=dusk.local
58 exec ./artisan dusk "$@"
59}
60
61
62_watch() {
63 yarn --network-timeout 100000
64 exec yarn watch
65}
66
67case "$command" in
68 artisan) exec ./artisan "$@";;
69 job|migrate|octane|schedule|test|watch) "_$command" "$@";;
70 *) exec "$command" "$@";;
71esac