-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathlaunch.sh
executable file
·139 lines (117 loc) · 4.51 KB
/
launch.sh
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env bash
# set to true if unset so set -u won't break us
: ${SOURCEGRAPH_COMBINE_CONFIG:=false}
set -euf -o pipefail
export GO111MODULE=on
go build ./pkg/version/minversion || {
echo "Go version 1.11.x or newer must be used to build Sourcegraph; found: $(go version)"
exit 1
}
unset CDPATH
cd "$(dirname "${BASH_SOURCE[0]}")/.." # cd to repo root dir
export GOMOD_ROOT="${GOMOD_ROOT:-$PWD}"
# Verify postgresql config.
hash psql 2>/dev/null || {
# "brew install [email protected]" does not put psql on the $PATH by default;
# try to fix this automatically if we can.
hash brew 2>/dev/null && {
if [[ -x "$(brew --prefix)/opt/[email protected]/bin/psql" ]]; then
export PATH="$(brew --prefix)/opt/[email protected]/bin:$PATH"
fi
}
}
if ! psql -wc '\x' >/dev/null; then
echo "FAIL: postgreSQL config invalid or missing OR postgreSQL is still starting up."
echo "You probably need, at least, PGUSER and PGPASSWORD set in the environment."
exit 1
fi
export LIGHTSTEP_INCLUDE_SENSITIVE=true
export PGSSLMODE=disable
# Default to "info" level debugging, and "condensed" log format (nice for human readers)
export SRC_LOG_LEVEL=${SRC_LOG_LEVEL:-info}
export SRC_LOG_FORMAT=${SRC_LOG_FORMAT:-condensed}
export GITHUB_BASE_URL=http://127.0.0.1:3180
export SRC_REPOS_DIR=$HOME/.sourcegraph/repos
export INSECURE_DEV=1
export SRC_GIT_SERVERS=127.0.0.1:3178
export SEARCHER_URL=http://127.0.0.1:3181
export REPO_UPDATER_URL=http://127.0.0.1:3182
export LSP_PROXY=127.0.0.1:4388
export REDIS_ENDPOINT=127.0.0.1:6379
export SRC_INDEXER=127.0.0.1:3179
export QUERY_RUNNER_URL=http://localhost:3183
export SYMBOLS_URL=http://localhost:3184
export CTAGS_COMMAND=${CTAGS_COMMAND-cmd/symbols/universal-ctags-dev}
export CTAGS_PROCESSES=1
export SRC_SYNTECT_SERVER=http://localhost:9238
export SRC_FRONTEND_INTERNAL=localhost:3090
export SRC_PROF_HTTP=
export SRC_PROF_SERVICES=$(cat dev/src-prof-services.json)
export OVERRIDE_AUTH_SECRET=sSsNGlI8fBDftBz0LDQNXEnP6lrWdt9g0fK6hoFvGQ
export DEPLOY_TYPE=dev
export SOURCEGRAPH_EXPAND_CONFIG_VARS=1 # experiment: interpolate ${var} and $var in site config JSON
# webpack-serve is a proxy running on port 3080 that (1) serves assets, waiting to respond until
# they are (re)built and (2) otherwise passes through to Sourcegraph running on port 3081. That is
# why Sourcegraph listens on 3081 despite the appURL having port 3080.
export WEBPACK_SERVE=1
export SRC_HTTP_ADDR=":3081"
# we want to keep config.json, but allow local config.
export SOURCEGRAPH_CONFIG_FILE=${SOURCEGRAPH_CONFIG_FILE:-./dev/config.json}
confpath="./dev"
fancyconfig() {
if ! ( cd dev/confmerge; go build ); then
echo >&2 "WARNING: Can't build confmerge in dev/confmerge, can't merge config files."
return 1
fi
if [ -f "$confpath/config_combined.json" ]; then
echo >&2 "Note: Moving existing config_combined.json to $confpath/config_backup.json."
mv $confpath/config_combined.json $confpath/config_backup.json
fi
if dev/confmerge/confmerge $confpath/config.json $confpath/config_local.json > $confpath/config_combined.json; then
echo >&2 "Successfully regenerated config_combined.json."
else
echo >&2 "FATAL: failed to generate config_combined.json."
rm $confpath/config_combined.json
return 1
fi
}
if $SOURCEGRAPH_COMBINE_CONFIG && [ -f $confpath/config_local.json ]; then
if ! fancyconfig; then
echo >&2 "WARNING: fancyconfig failed. Giving up. Use SOURCEGRAPH_COMBINE_CONFIG=false to bypass."
exit 1
fi
SOURCEGRAPH_CONFIG_FILE=$confpath/config_combined.json
fi
if ! [ -z "${ZOEKT-}" ]; then
export ZOEKT_HOST=localhost:6070
else
export ZOEKT_HOST=
fi
# WebApp
export NODE_ENV=development
export NODE_OPTIONS="--max_old_space_size=4096"
# Make sure chokidar-cli is installed in the background
printf >&2 "Concurrently installing Yarn and Go dependencies...\n\n"
yarn_pid=''
[ -n "${OFFLINE-}" ] || {
yarn --no-progress &
yarn_pid="$!"
}
if ! ./dev/go-install.sh; then
# let Yarn finish, otherwise we get Yarn diagnostics AFTER the
# actual reason we're failing.
wait
echo >&2 "WARNING: go-install.sh failed, some builds may have failed."
exit 1
fi
# Wait for yarn if it is still running
if [[ -n "$yarn_pid" ]]; then
wait "$yarn_pid"
fi
# Increase ulimit (not needed on Windows/WSL)
type ulimit > /dev/null && ulimit -n 10000 || true
# Put .bin:node_modules/.bin onto the $PATH
export PATH="$PWD/.bin:$PWD/node_modules/.bin:$PATH"
printf >&2 "\nStarting all binaries...\n\n"
export GOREMAN="goreman --set-ports=false --exit-on-error -f ${PROCFILE:-dev/Procfile}"
exec $GOREMAN start