Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
hive
hivemind
Commits
c432399b
Commit
c432399b
authored
2 months ago
by
Dan Notestein
Browse files
Options
Downloads
Patches
Plain Diff
Add an argument to set the statement timeout for the API user
parent
1690a789
No related branches found
No related tags found
1 merge request
!846
Create a new hivemind_user database user to be used when serving
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docker/docker_entrypoint.sh
+13
-4
13 additions, 4 deletions
docker/docker_entrypoint.sh
haf
+1
-1
1 addition, 1 deletion
haf
scripts/setup_postgres.sh
+15
-5
15 additions, 5 deletions
scripts/setup_postgres.sh
with
29 additions
and
10 deletions
docker/docker_entrypoint.sh
+
13
−
4
View file @
c432399b
...
...
@@ -28,9 +28,9 @@ INSTALL_APP=0
DO_SCHEMA_UPGRADE
=
0
WITH_REPTRACKER
=
0
REPTRACKER_SCHEMA
=
reptracker_app
STATEMENT_TIMEOUT
=
""
reptracker_dir
=
"
$SCRIPT_DIR
/app/reputation_tracker"
while
[
$#
-gt
0
]
;
do
case
"
$1
"
in
--database-url
=
*
)
...
...
@@ -44,6 +44,9 @@ while [ $# -gt 0 ]; do
export
POSTGRES_URL
=
"
${
1
#*=
}
"
export
POSTGRES_ADMIN_URL
=
"
${
1
#*=
}
"
;;
--statement-timeout
=
*
)
STATEMENT_TIMEOUT
=
"
${
1
#*=
}
"
;;
--add-mocks
=
*
)
ADD_MOCKS
=
"
${
1
#*=
}
"
;;
...
...
@@ -65,7 +68,8 @@ while [ $# -gt 0 ]; do
;;
*
)
arg
=
$1
[[
-n
"
${
arg
}
"
]]
&&
HIVEMIND_ARGS+
=(
"
${
arg
}
"
)
[[
-n
"
${
arg
}
"
]]
&&
HIVEMIND_ARGS+
=(
"
${
arg
}
"
)
;;
esac
shift
done
...
...
@@ -113,7 +117,12 @@ run_hive() {
setup
()
{
log
"setup"
"Setting up the database..."
cd
/home/hivemind/app
./setup_postgres.sh
--postgres-url
=
"
${
POSTGRES_ADMIN_URL
}
"
# If STATEMENT_TIMEOUT was provided, pass it to setup_postgres.sh
if
[[
-n
"
${
STATEMENT_TIMEOUT
}
"
]]
;
then
./setup_postgres.sh
--postgres-url
=
"
${
POSTGRES_ADMIN_URL
}
"
--statement-timeout
=
"
${
STATEMENT_TIMEOUT
}
"
else
./setup_postgres.sh
--postgres-url
=
"
${
POSTGRES_ADMIN_URL
}
"
fi
if
[
"
${
WITH_REPTRACKER
}
"
-eq
1
]
;
then
# if we force to install rep tracker then we setup it as non-forking app
...
...
@@ -124,7 +133,7 @@ setup() {
fi
./install_app.sh
--reptracker-schema-name
=
"
${
REPTRACKER_SCHEMA
}
"
--postgres-url
=
"
${
POSTGRES_ADMIN_URL
}
"
if
[[
"
$ADD_MOCKS
"
==
"true"
]]
;
then
log
"setup"
"Adding mocks to database..."
# shellcheck source=/dev/null
...
...
This diff is collapsed.
Click to expand it.
haf
@
40a77e18
Compare
a2479052
...
40a77e18
Subproject commit
a247905233f6d38e34b6d535798e02fafa643664
Subproject commit
40a77e182a3a00af18479755d5eb43d8b76070d8
This diff is collapsed.
Click to expand it.
scripts/setup_postgres.sh
+
15
−
5
View file @
c432399b
...
...
@@ -11,7 +11,7 @@ source "$SCRIPTPATH/common.sh"
log_exec_params
"
$@
"
# Script reponsible for setup of specified postgres instance.
# Script re
s
ponsible for setup of specified postgres instance.
#
# - creates all builtin hivemind roles on pointed PostgreSQL server instance
...
...
@@ -20,10 +20,11 @@ print_help () {
echo
echo
"Allows to setup a database already filled by HAF instance, to work with hivemind application."
echo
"OPTIONS:"
echo
" --host=VALUE Allows to specify a PostgreSQL host location (defaults to /var/run/postgresql)"
echo
" --port=NUMBER Allows to specify a PostgreSQL operating port (defaults to 5432)"
echo
" --postgres-url=URL Allows to specify a PostgreSQL URL (in opposite to separate --host and --port options)"
echo
" --help Display this help screen and exit"
echo
" --host=VALUE Allows to specify a PostgreSQL host location (defaults to /var/run/postgresql)"
echo
" --port=NUMBER Allows to specify a PostgreSQL operating port (defaults to 5432)"
echo
" --postgres-url=URL Allows to specify a PostgreSQL URL (in opposite to separate --host and --port options)"
echo
" --statement-timeout=VALUE Set the statement_timeout for the hivemind_user role (e.g., 10s)"
echo
" --help Display this help screen and exit"
echo
}
...
...
@@ -37,6 +38,7 @@ supplement_builtin_roles() {
POSTGRES_HOST
=
"/var/run/postgresql"
POSTGRES_PORT
=
5432
POSTGRES_URL
=
""
STATEMENT_TIMEOUT
=
""
while
[
$#
-gt
0
]
;
do
case
"
$1
"
in
...
...
@@ -49,6 +51,9 @@ while [ $# -gt 0 ]; do
--postgres-url
=
*
)
export
POSTGRES_URL
=
"
${
1
#*=
}
"
;;
--statement-timeout
=
*
)
STATEMENT_TIMEOUT
=
"
${
1
#*=
}
"
;;
--help
)
print_help
exit
0
...
...
@@ -81,3 +86,8 @@ fi
#psql "$POSTGRES_ACCESS" -c "GRANT SET ON PARAMETER log_min_messages TO hivemind;"
supplement_builtin_roles
"
$POSTGRES_ACCESS
"
if
[
-n
"
$STATEMENT_TIMEOUT
"
]
;
then
echo
"Setting statement timeout for hivemind_user role to
${
STATEMENT_TIMEOUT
}
..."
psql
"
$POSTGRES_ACCESS
"
-v
ON_ERROR_STOP
=
on
-c
"ALTER ROLE hivemind_user SET statement_timeout TO '
${
STATEMENT_TIMEOUT
}
';"
fi
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