Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
9460af9e
Commit
9460af9e
authored
4 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Override container-deploy updateRouting
parent
89deb1d3
No related branches found
No related tags found
2 merge requests
!146
Release CMO metadata to production
,
!50
Override container-deploy updateRouting
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/custom.funcs.sh
+65
-0
65 additions, 0 deletions
scripts/custom.funcs.sh
with
65 additions
and
0 deletions
scripts/custom.funcs.sh
+
65
−
0
View file @
9460af9e
...
@@ -5,6 +5,71 @@ preStackDeployHook () {
...
@@ -5,6 +5,71 @@ preStackDeployHook () {
writeYmlFile
;
writeYmlFile
;
}
}
##
# override the default updateRouting, which adds a trailing slash...
##
updateRouting
()
{
local
appName
=
$1
;
shift
;
local
stackName
=
$1
;
shift
;
local
serviceMap
=
$@
;
local dir
=
"
$(
pwd
-P
)
"
;
local
stamp
=
$(
date
)
;
local
configFile
=
"
${
dir
}
/
${
appName
}
.conf"
;
local
serverFile
=
"
${
dir
}
/
${
appName
}
.server"
;
local
upstreamIdx
=
0
;
debug
"Re-routing traffic to
${
stackName
}
stack."
;
echo
"# Auto generated
${
stamp
}
for
${
stackName
}
"
>
$configFile
;
echo
"# Auto generated
${
stamp
}
for
${
stackName
}
"
>
$serverFile
;
for
service
in
${
serviceMap
[@]
}
;
do
local
name
=
"
${
stackName
}
_
$(
echo
$service
|
awk
-F
:
'{print $2}'
)
"
;
local
upstreamName
=
"
${
name
}
_
${
upstreamIdx
}
"
;
local
path
=
"
$(
echo
$service
|
awk
-F
:
'{print $1}'
)
"
;
local
port
=
$(
getPublishedPort
$name
2> /dev/null
)
;
if
[
-z
"
${
port
}
"
]
;
then
# No port exposed. Continue.
debug
"No port exposed for
${
name
}
. Not routing. Moving on."
;
continue
;
fi
echo
"upstream
${
upstreamName
}
{"
>>
$configFile
;
for
host
in
${
TARGET_HOSTS
[@]
}
;
do
echo
" server
${
host
}
:
${
port
}
;"
>>
$configFile
;
done
echo
"}"
>>
$configFile
;
cat
<<-
EO_SERVER_SNIP
>>
$serverFile
# do not include trailing slash here, map can if needed
location
${
path
}
{
proxy_pass http://
${
upstreamName
}
;
proxy_connect_timeout 5s;
proxy_set_header Host
\$
host;
proxy_set_header X-Client-IP
\$
remote_addr;
proxy_set_header X-Forwarded-For
\$
proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
# clean up any redirects sent by proxy
proxy_redirect http://
${
proxy_host
}${
path
}
https://
\$
host
${
path
}
;
}
EO_SERVER_SNIP
# ^^ Note: TAB indentation required
upstreamIdx
=
$((
upstreamIdx
+
1
))
;
done
if
[
$(
configsDiffer
${
appName
}
${
configFile
}
${
serverFile
}
)
]
;
then
debug
"Updating configuration for
${
appName
}
"
;
routerConfig
--update
${
appName
}
${
configFile
}
${
serverFile
}
;
else
debug
"
${
appName
}
configuration not changed. Skipping router update."
;
fi
}
##
##
# Write a customized YML file for deploying the stack. Necessary because
# Write a customized YML file for deploying the stack. Necessary because
# by default, YML files do not allow variables for defining configs.
# by default, YML files do not allow variables for defining configs.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment