1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | import os from 'os'
|
23 |
|
24 | import { config } from '../src/config'
|
25 | import { Doctor } from '../src/doctor'
|
26 | import { Wechaty } from '../src/wechaty'
|
27 |
|
28 | const wechaty = Wechaty.instance()
|
29 | const doctor = new Doctor()
|
30 |
|
31 | async function main () {
|
32 | let ipcTestResult: string
|
33 | try {
|
34 | await doctor.testTcp()
|
35 | ipcTestResult = 'PASS'
|
36 | } catch (err) {
|
37 | console.info(err)
|
38 | ipcTestResult = 'FAIL. Please check your tcp network, Wechaty need to listen on localhost and connect to it.'
|
39 | }
|
40 |
|
41 | console.info(`
|
42 | #### Wechaty Doctor
|
43 |
|
44 | 1. Wechaty version: ${wechaty.version()}
|
45 | 2. ${os.type()} ${os.arch()} version ${os.release()} memory ${Math.floor(os.freemem() / 1024 / 1024)}/${Math.floor(os.totalmem() / 1024 / 1024)} MB
|
46 | 3. Docker: ${config.docker}
|
47 | 4. Node version: ${process.version}
|
48 | 5. Tcp IPC TEST: ${ipcTestResult}
|
49 |
|
50 | `)
|
51 |
|
52 | }
|
53 |
|
54 | main()
|
55 | .catch(err => console.error('main() exception: %s', err))
|