melo-example-robot 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app.ts ADDED
@@ -0,0 +1,34 @@
1
+ let envConfig = require('./app/config/env.json');
2
+ let config = require('./app/config/' + envConfig.env + '/config');
3
+ import { Robot } from '@bigtyphoon/melo-robot';
4
+ import * as fs from 'fs';
5
+
6
+ let robot = new Robot(config);
7
+ let mode = 'master';
8
+
9
+ if (process.argv.length > 2) {
10
+ mode = process.argv[2];
11
+ }
12
+
13
+ if (mode !== 'master' && mode !== 'client') {
14
+ throw new Error(' mode must be master or client');
15
+ }
16
+
17
+ if (mode === 'master') {
18
+ robot.runMaster(__filename);
19
+ } else {
20
+ let script = (process.cwd() + envConfig.script);
21
+ script = script.replace(/\\/g, '/');
22
+ robot.runAgent(script);
23
+ }
24
+
25
+ process.on('uncaughtException', function (err) {
26
+ /* temporary code */
27
+ console.error(' Caught exception: ' + err.stack);
28
+ if (!!robot && !!robot.agent) {
29
+ // robot.agent.socket.emit('crash', err.stack);
30
+ }
31
+ fs.appendFile('./log/.log', err.stack, function (err) {
32
+ });
33
+ /* temporary code */
34
+ });
@@ -0,0 +1,3 @@
1
+ {
2
+ "master": {"host": "127.0.0.1", "port":8888, "webport":8889,"cwebport":8887, "interval":500}
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "env":"dev",
3
+ "script":"/app/script/Client.js"
4
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "master": {"host": "127.0.0.1", "port":8888, "webport":8889,"cwebport":8887, "interval":500}
3
+ }