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
7d730f67
Unverified
Commit
7d730f67
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring: Extract showMachineInfo function
parent
6bda5716
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/index.ts
+2
-14
2 additions, 14 deletions
src/index.ts
src/misc/show-machine-info.ts
+15
-0
15 additions, 0 deletions
src/misc/show-machine-info.ts
with
17 additions
and
14 deletions
src/index.ts
+
2
−
14
View file @
7d730f67
...
...
@@ -12,7 +12,6 @@ import chalk from 'chalk';
import
*
as
portscanner
from
'
portscanner
'
;
import
*
as
isRoot
from
'
is-root
'
;
import
Xev
from
'
xev
'
;
import
*
as
sysUtils
from
'
systeminformation
'
;
import
Logger
from
'
./misc/logger
'
;
import
serverStats
from
'
./daemons/server-stats
'
;
...
...
@@ -23,6 +22,7 @@ import { lessThan } from './prelude/array';
import
*
as
pkg
from
'
../package.json
'
;
import
{
program
}
from
'
./argv
'
;
import
{
checkMongoDB
}
from
'
./misc/check-mongodb
'
;
import
{
showMachineInfo
}
from
'
./misc/show-machine-info
'
;
const
logger
=
new
Logger
(
'
core
'
,
'
cyan
'
);
const
bootLogger
=
logger
.
createSubLogger
(
'
boot
'
,
'
magenta
'
);
...
...
@@ -121,18 +121,6 @@ async function isPortAvailable(port: number): Promise<boolean> {
return
await
portscanner
.
checkPortStatus
(
port
,
'
127.0.0.1
'
)
===
'
closed
'
;
}
async
function
showMachine
()
{
const
logger
=
bootLogger
.
createSubLogger
(
'
machine
'
);
logger
.
debug
(
`Hostname:
${
os
.
hostname
()}
`
);
logger
.
debug
(
`Platform:
${
process
.
platform
}
`
);
logger
.
debug
(
`Architecture:
${
process
.
arch
}
`
);
logger
.
debug
(
`CPU:
${
os
.
cpus
().
length
}
core`
);
const
mem
=
await
sysUtils
.
mem
();
const
totalmem
=
(
mem
.
total
/
1024
/
1024
/
1024
).
toFixed
(
1
);
const
availmem
=
(
mem
.
available
/
1024
/
1024
/
1024
).
toFixed
(
1
);
logger
.
debug
(
`MEM:
${
totalmem
}
GB (available:
${
availmem
}
GB)`
);
}
function
showEnvironment
():
void
{
const
env
=
process
.
env
.
NODE_ENV
;
const
logger
=
bootLogger
.
createSubLogger
(
'
env
'
);
...
...
@@ -161,7 +149,7 @@ async function init(): Promise<Config> {
process
.
exit
(
1
);
}
await
showMachine
(
);
await
showMachine
Info
(
bootLogger
);
const
configLogger
=
bootLogger
.
createSubLogger
(
'
config
'
);
let
config
;
...
...
This diff is collapsed.
Click to expand it.
src/misc/show-machine-info.ts
0 → 100644
+
15
−
0
View file @
7d730f67
import
*
as
os
from
'
os
'
;
import
*
as
sysUtils
from
'
systeminformation
'
;
import
Logger
from
"
./logger
"
;
export
async
function
showMachineInfo
(
parentLogger
:
Logger
)
{
const
logger
=
parentLogger
.
createSubLogger
(
'
machine
'
);
logger
.
debug
(
`Hostname:
${
os
.
hostname
()}
`
);
logger
.
debug
(
`Platform:
${
process
.
platform
}
`
);
logger
.
debug
(
`Architecture:
${
process
.
arch
}
`
);
logger
.
debug
(
`CPU:
${
os
.
cpus
().
length
}
core`
);
const
mem
=
await
sysUtils
.
mem
();
const
totalmem
=
(
mem
.
total
/
1024
/
1024
/
1024
).
toFixed
(
1
);
const
availmem
=
(
mem
.
available
/
1024
/
1024
/
1024
).
toFixed
(
1
);
logger
.
debug
(
`MEM:
${
totalmem
}
GB (available:
${
availmem
}
GB)`
);
}
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