Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
b62203b1
Commit
b62203b1
authored
6 years ago
by
Aya Morisawa
Committed by
syuilo
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Check MongoDB version (#3185)
* Check MongoDB version * Fix bug
parent
16136c25
No related branches found
Branches containing commit
Tags
11.34.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/index.ts
+13
-4
13 additions, 4 deletions
src/index.ts
src/prelude/array.ts
+8
-0
8 additions, 0 deletions
src/prelude/array.ts
with
21 additions
and
4 deletions
src/index.ts
+
13
−
4
View file @
b62203b1
...
...
@@ -14,7 +14,7 @@ import * as portscanner from 'portscanner';
import
isRoot
=
require
(
'
is-root
'
);
import
Xev
from
'
xev
'
;
import
*
as
program
from
'
commander
'
;
import
mongo
from
'
./db/mongodb
'
;
import
mongo
,
{
nativeDbConn
}
from
'
./db/mongodb
'
;
import
Logger
from
'
./misc/logger
'
;
import
EnvironmentInfo
from
'
./misc/environmentInfo
'
;
...
...
@@ -23,6 +23,7 @@ import serverStats from './daemons/server-stats';
import
notesStats
from
'
./daemons/notes-stats
'
;
import
loadConfig
from
'
./config/load
'
;
import
{
Config
}
from
'
./config/types
'
;
import
{
lessThan
}
from
'
./prelude/array
'
;
const
clusterLog
=
debug
(
'
misskey:cluster
'
);
const
ev
=
new
Xev
();
...
...
@@ -158,11 +159,19 @@ function checkMongoDb(config: Config) {
mongoDBLogger
.
info
(
`Connecting to
${
uri
}
`
);
mongo
.
then
(()
=>
{
nativeDbConn
().
then
(
db
=>
db
.
admin
().
serverInfo
()).
then
(
x
=>
x
.
version
).
then
((
version
:
string
)
=>
{
mongoDBLogger
.
info
(
`Version:
${
version
}
`
);
if
(
lessThan
(
version
.
split
(
'
.
'
).
map
(
x
=>
parseInt
(
x
,
10
)),
[
3
,
6
]))
{
mongoDBLogger
.
error
(
`MongoDB version is less than 3.6. Please upgrade it.`
);
process
.
exit
(
1
);
}
});
mongoDBLogger
.
succ
(
'
Connectivity confirmed
'
);
})
.
catch
(
err
=>
{
mongoDBLogger
.
error
(
err
.
message
);
});
.
catch
(
err
=>
{
mongoDBLogger
.
error
(
err
.
message
);
});
}
function
spawnWorkers
(
limit
:
number
)
{
...
...
This diff is collapsed.
Click to expand it.
src/prelude/array.ts
+
8
−
0
View file @
b62203b1
...
...
@@ -49,3 +49,11 @@ export function groupBy<T>(f: (x: T, y: T) => boolean, xs: T[]): T[][] {
export
function
groupOn
<
T
,
S
>
(
f
:
(
x
:
T
)
=>
S
,
xs
:
T
[]):
T
[][]
{
return
groupBy
((
a
,
b
)
=>
f
(
a
)
===
f
(
b
),
xs
);
}
export
function
lessThan
(
xs
:
number
[],
ys
:
number
[]):
boolean
{
for
(
let
i
=
0
;
i
<
Math
.
min
(
xs
.
length
,
ys
.
length
);
i
++
)
{
if
(
xs
[
i
]
<
ys
[
i
])
return
true
;
if
(
xs
[
i
]
>
ys
[
i
])
return
false
;
}
return
xs
.
length
<
ys
.
length
;
}
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