Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
a6b307c1
Commit
a6b307c1
authored
9 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Initialization progress bar
parent
759f42d0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
resources/frontend_client/init.html
+27
-4
27 additions, 4 deletions
resources/frontend_client/init.html
src/metabase/api/routes.clj
+1
-1
1 addition, 1 deletion
src/metabase/api/routes.clj
src/metabase/core.clj
+16
-4
16 additions, 4 deletions
src/metabase/core.clj
with
44 additions
and
9 deletions
resources/frontend_client/init.html
+
27
−
4
View file @
a6b307c1
...
...
@@ -5,11 +5,34 @@
<title>
Metabase
</title>
</head>
<body>
Initializing Metabase, please wait...
<h3>
Initializing Metabase, please wait...
</h3>
<div>
<progress
id=
"progress"
max=
"100"
value=
"0"
></progress>
</div>
<script
type=
"text/javascript"
>
setTimeout
(
function
()
{
window
.
location
.
reload
();
},
2500
);
function
poll
()
{
var
req
=
new
XMLHttpRequest
();
req
.
open
(
"
GET
"
,
"
/api/health
"
,
true
);
req
.
onreadystatechange
=
function
()
{
if
(
req
.
readyState
===
4
)
{
if
(
req
.
status
===
200
)
{
window
.
location
.
reload
();
}
else
{
try
{
var
health
=
JSON
.
parse
(
req
.
responseText
);
if
(
typeof
health
.
progress
===
"
number
"
)
{
document
.
getElementById
(
"
progress
"
).
value
=
health
.
progress
*
100
;
}
}
catch
(
e
)
{}
setTimeout
(
poll
,
500
);
}
}
}
req
.
send
();
}
poll
();
</script>
</body>
</html>
This diff is collapsed.
Click to expand it.
src/metabase/api/routes.clj
+
1
−
1
View file @
a6b307c1
...
...
@@ -37,7 +37,7 @@
(
context
"/foreignkey"
[]
(
+auth
fk/routes
))
(
GET
"/health"
[]
(
if
((
resolve
'metabase.core/initialized?
))
{
:status
200
:body
{
:status
"ok"
}}
{
:status
503
:body
{
:status
"initializing"
}}))
{
:status
503
:body
{
:status
"initializing"
:progress
((
resolve
'metabase.core/initialization-progress
))
}}))
(
context
"/notify"
[]
(
+apikey
notify/routes
))
(
context
"/revision"
[]
(
+auth
revision/routes
))
(
context
"/session"
[]
session/routes
)
...
...
This diff is collapsed.
Click to expand it.
src/metabase/core.clj
+
16
−
4
View file @
a6b307c1
...
...
@@ -71,13 +71,18 @@
;;; ## ---------------------------------------- LIFECYCLE ----------------------------------------
(
def
^
:private
metabase-initializ
ed
(
atom
false
))
(
def
^
:private
metabase-initializ
ation-progress
(
atom
0
))
(
defn
initialized?
"Metabase is initialized and ready to be served"
[]
@
metabase-initialized
)
(
=
@
metabase-initialization-progress
1.0
))
(
defn
initialization-progress
"Metabase is initialized and ready to be served"
[]
@
metabase-initialization-progress
)
(
defn-
-init-create-setup-token
"Create and set a new setup token, and open the setup URL on the user's system."
...
...
@@ -104,11 +109,15 @@
"General application initialization function which should be run once at application startup."
[]
(
log/info
(
format
"Starting Metabase version %s..."
(
config/mb-version-string
)))
(
reset!
metabase-initialization-progress
0.1
)
;; First of all, lets register a shutdown hook that will tidy things up for us on app exit
(
.addShutdownHook
(
Runtime/getRuntime
)
(
Thread.
^
Runnable
destroy
))
(
reset!
metabase-initialization-progress
0.3
)
;; startup database. validates connection & runs any necessary migrations
(
db/setup-db
:auto-migrate
(
config/config-bool
:mb-db-automigrate
))
(
reset!
metabase-initialization-progress
0.5
)
;; run a very quick check to see if we are doing a first time installation
;; the test we are using is if there is at least 1 User in the database
...
...
@@ -116,9 +125,11 @@
;; Bootstrap the event system
(
events/initialize-events!
)
(
reset!
metabase-initialization-progress
0.7
)
;; Now start the task runner
(
task/start-scheduler!
)
(
reset!
metabase-initialization-progress
0.8
)
(
when
new-install
(
log/info
"Looks like this is a new installation ... preparing setup wizard"
)
...
...
@@ -126,6 +137,7 @@
(
-init-create-setup-token
)
;; publish install event
(
events/publish-event
:install
{}))
(
reset!
metabase-initialization-progress
0.9
)
;; deal with our sample dataset as needed
(
if
new-install
...
...
@@ -135,7 +147,7 @@
(
sample-data/update-sample-dataset-if-needed!
)))
(
log/info
"Metabase Initialization COMPLETE"
)
(
reset!
metabase-initializ
ed
true
)
(
reset!
metabase-initializ
ation-progress
1.0
)
true
)
...
...
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