Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6ad34183
Commit
6ad34183
authored
Feb 12, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
48f2d033
885e2a9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
lib/tasks/gitlab/setup.rake
lib/tasks/gitlab/setup.rake
+25
-0
No files found.
lib/tasks/gitlab/setup.rake
View file @
6ad34183
...
...
@@ -25,6 +25,11 @@ namespace :gitlab do
puts
""
end
# In production, we might want to prevent ourselves from shooting
# ourselves in the foot, so let's only do this in a test or
# development environment.
terminate_all_connections
unless
Rails
.
env
.
production?
Rake
::
Task
[
"db:reset"
].
invoke
Rake
::
Task
[
"add_limits_mysql"
].
invoke
Rake
::
Task
[
"setup_postgresql"
].
invoke
...
...
@@ -33,4 +38,24 @@ namespace :gitlab do
puts
"Quitting..."
.
color
(
:red
)
exit
1
end
# If there are any clients connected to the DB, PostgreSQL won't let
# you drop the database. It's possible that Sidekiq, Unicorn, or
# some other client will be hanging onto a connection, preventing
# the DROP DATABASE from working. To workaround this problem, this
# method terminates all the connections so that a subsequent DROP
# will work.
def
self
.
terminate_all_connections
return
false
unless
Gitlab
::
Database
.
postgresql?
cmd
=
<<~
SQL
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE datname = current_database()
AND pid <> pg_backend_pid();
SQL
ActiveRecord
::
Base
.
connection
.
execute
(
cmd
)
&
.
result_status
==
PG
::
PGRES_TUPLES_OK
rescue
ActiveRecord
::
NoDatabaseError
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment