whatap 0.4.51 → 0.4.54

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/help.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  //whatap.conf를 다른 것으로 사용하고 싶을때
2
- process.env.WHATAP_CONF = "wtap";
2
+ process.env.WHATAP_CONF = "whatap";
3
3
  process.env.WHATAP_NAME = "NODE-{ip2}-{ip3}"
4
4
 
5
5
  //플러그인추가
package/lib/core/agent.js CHANGED
@@ -7,6 +7,7 @@
7
7
  var os = require('os'),
8
8
  fs = require('fs'),
9
9
  path = require('path');
10
+
10
11
  const RequestLog = require('../requestlog');
11
12
 
12
13
  var Interceptor = require('./interceptor').Interceptor,
@@ -4,154 +4,156 @@
4
4
  * can be found in the LICENSE file.
5
5
  */
6
6
 
7
- var fs = require('fs'),
8
- path = require('path');
9
-
7
+ var fs = require('fs'),
8
+ path = require('path'),
9
+ hahsUtil = require('../util/hashutil2'),
10
+ IPUtil = require('../util/iputil');
10
11
  function isLiveProcess(pid) {
11
- if(!pid || pid.length === 0) return true;
12
+ if(!pid || pid.length === 0) return true;
12
13
 
13
- try {
14
- return process.kill(pid,0)
15
- }
16
- catch (e) {
17
- return e.code === 'EPERM'
18
- }
14
+ try {
15
+ return process.kill(pid,0)
16
+ }
17
+ catch (e) {
18
+ return e.code === 'EPERM'
19
+ }
19
20
  }
20
21
 
21
22
  function LockCompetition(key){
22
- this.MAIN_KEY = key;
23
- var Configuration = require('./../conf/configure');
24
- var root = Configuration['app.root'];
25
- var cwd = process.cwd();
26
- if(root == undefined) {
27
- root = cwd;
28
- }
29
- this.rootFolder = path.join(root,'SSwhatapSS').replace('SSwhatapSS','\.'+key);
30
- this.LOCK_FILE = path.join(this.rootFolder,this.MAIN_KEY+'.lock');
31
- this.initComplete = false;
23
+ this.MAIN_KEY = key;
24
+ var Configuration = require('./../conf/configure');
25
+ var root = Configuration['app.root'];
26
+ var cwd = process.cwd();
27
+ if(root == undefined) {
28
+ root = cwd;
29
+ }
30
+ let gubun = hahsUtil.hash(IPUtil.getIp());
31
+ this.rootFolder = path.join(root,'SSwhatapSS').replace('SSwhatapSS','\.'+key + '/' + gubun);
32
+ this.LOCK_FILE = path.join(this.rootFolder,this.MAIN_KEY+'.lock');
33
+ this.initComplete = false;
32
34
  }
33
35
 
34
36
  LockCompetition.prototype.init = function(cb){
35
- if(this.initComplete) {
36
- if(cb) cb();
37
- }
38
- fs.mkdir( this.rootFolder, function(err){
39
- if(!err || err.code === 'EEXIST'){
40
- this.initComplete = true;
41
- if(cb) cb();
42
- }else{
43
- return console.error(err);
44
- }
45
- });
37
+ if(this.initComplete) {
38
+ if(cb) cb();
39
+ }
40
+ fs.mkdir( this.rootFolder, function(err){
41
+ if(!err || err.code === 'EEXIST'){
42
+ this.initComplete = true;
43
+ if(cb) cb();
44
+ }else{
45
+ return console.error(err);
46
+ }
47
+ });
46
48
  }
47
49
 
48
50
  LockCompetition.prototype.accessAuth = function(cb){
49
- var self = this;
50
- self.init(function(){
51
- var i = setInterval(function(){
52
- self.createLockFile(path.join(self.LOCK_FILE), function(result){
53
- if(result){
54
- self.checkFileIndex(1, function(idx){
55
- self.releaseLockFile( function(result){
56
- if(result){
57
- cb(idx);
58
- clearInterval(i);
59
- }
60
- })
61
- })
62
- }
63
- })
64
- },10)
65
- });
51
+ var self = this;
52
+ self.init(function(){
53
+ var i = setInterval(function(){
54
+ self.createLockFile(path.join(self.LOCK_FILE), function(result){
55
+ if(result){
56
+ self.checkFileIndex(1, function(idx){
57
+ self.releaseLockFile( function(result){
58
+ if(result){
59
+ cb(idx);
60
+ clearInterval(i);
61
+ }
62
+ })
63
+ })
64
+ }
65
+ })
66
+ },10)
67
+ });
66
68
  }
67
69
 
68
70
  LockCompetition.prototype.readLockFile = function(cb){
69
- fs.readFile( this.LOCK_FILE, 'utf-8', function(err,data){
70
- if(cb) cb(err, data);
71
- });
71
+ fs.readFile( this.LOCK_FILE, 'utf-8', function(err,data){
72
+ if(cb) cb(err, data);
73
+ });
72
74
  }
73
75
 
74
76
  LockCompetition.prototype.createLockFile = function(file, cb){
75
- var self = this;
76
- self.readLockFile(function(err, data){
77
- if(err){
78
- fs.writeFile(file, process.pid + '', 'utf-8', function(err,data){
79
- if(err){
80
- if(cb) return cb(false);
81
- }else{
82
- self.readLockFile( function(err, data){
83
- if(err && cb) return cb(false);
84
- if(parseInt(data) === process.pid){
85
- if(cb) return cb(true);
86
- }else{
87
- if(cb) return cb(false);
88
- }
89
- });
90
- }
91
- });
92
- }else{
93
- if(isLiveProcess(data)){
94
- if(cb) return cb(false);
95
- }else{
96
- fs.unlink(self.LOCK_FILE, function(err){
97
- if(err){
98
- if(cb) return cb(false);
99
- }else{
100
- if(cb) return cb(true);
101
- }
102
- });
103
- }
104
- }
105
- });
77
+ var self = this;
78
+ self.readLockFile(function(err, data){
79
+ if(err){
80
+ fs.writeFile(file, process.pid + '', 'utf-8', function(err,data){
81
+ if(err){
82
+ if(cb) return cb(false);
83
+ }else{
84
+ self.readLockFile( function(err, data){
85
+ if(err && cb) return cb(false);
86
+ if(parseInt(data) === process.pid){
87
+ if(cb) return cb(true);
88
+ }else{
89
+ if(cb) return cb(false);
90
+ }
91
+ });
92
+ }
93
+ });
94
+ }else{
95
+ if(isLiveProcess(data)){
96
+ if(cb) return cb(false);
97
+ }else{
98
+ fs.unlink(self.LOCK_FILE, function(err){
99
+ if(err){
100
+ if(cb) return cb(false);
101
+ }else{
102
+ if(cb) return cb(true);
103
+ }
104
+ });
105
+ }
106
+ }
107
+ });
106
108
  }
107
109
 
108
110
  LockCompetition.prototype.releaseLockFile = function(cb){
109
- var self = this;
110
- fs.readFile(self.LOCK_FILE, 'utf-8', function(err,data){
111
- if(err && cb) return cb(err, data);
111
+ var self = this;
112
+ fs.readFile(self.LOCK_FILE, 'utf-8', function(err,data){
113
+ if(err && cb) return cb(err, data);
112
114
 
113
- if(parseInt(data) === process.pid){
114
- fs.unlink(self.LOCK_FILE, function(err){
115
- if(err){
116
- if(cb) return cb(false);
117
- }else{
118
- if(cb) return cb(true);
119
- }
120
- });
121
- }else{
122
- if(cb) return cb(false);
123
- }
124
- });
115
+ if(parseInt(data) === process.pid){
116
+ fs.unlink(self.LOCK_FILE, function(err){
117
+ if(err){
118
+ if(cb) return cb(false);
119
+ }else{
120
+ if(cb) return cb(true);
121
+ }
122
+ });
123
+ }else{
124
+ if(cb) return cb(false);
125
+ }
126
+ });
125
127
  }
126
128
 
127
129
  LockCompetition.prototype.checkFileIndex = function(idx,cb){
128
- var self = this;
129
- idx = idx || 1;
130
- fs.readFile(path.join(self.rootFolder, self.MAIN_KEY+idx), 'utf-8', function(err,data){
131
- if(err){
132
- fs.writeFile(path.join(self.rootFolder, self.MAIN_KEY+idx), process.pid + '', 'utf-8', function(err){
133
- if(err){
134
- self.checkFileIndex(++idx,cb);
135
- }else{
136
- if(cb) cb(idx);
137
- }
138
- });
139
- }else{
140
- if( isLiveProcess(data) ){
141
- self.checkFileIndex(++idx,cb);
142
- }else{
143
- fs.writeFile(path.join(self.rootFolder, self.MAIN_KEY+idx), process.pid + '', 'utf-8', function(result){
144
- if(err){
145
- self.checkFileIndex(++idx,cb);
146
- }else{
147
- if(cb) cb(idx);
148
- }
149
- });
150
- }
151
- }
152
- })
130
+ var self = this;
131
+ idx = idx || 1;
132
+ fs.readFile(path.join(self.rootFolder, self.MAIN_KEY+idx), 'utf-8', function(err,data){
133
+ if(err){
134
+ fs.writeFile(path.join(self.rootFolder, self.MAIN_KEY+idx), process.pid + '', 'utf-8', function(err){
135
+ if(err){
136
+ self.checkFileIndex(++idx,cb);
137
+ }else{
138
+ if(cb) cb(idx);
139
+ }
140
+ });
141
+ }else{
142
+ if( isLiveProcess(data) ){
143
+ self.checkFileIndex(++idx,cb);
144
+ }else{
145
+ fs.writeFile(path.join(self.rootFolder, self.MAIN_KEY+idx), process.pid + '', 'utf-8', function(result){
146
+ if(err){
147
+ self.checkFileIndex(++idx,cb);
148
+ }else{
149
+ if(cb) cb(idx);
150
+ }
151
+ });
152
+ }
153
+ }
154
+ })
153
155
  }
154
156
 
155
157
  module.exports = function(key){
156
- return new LockCompetition(key);
158
+ return new LockCompetition(key);
157
159
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "whatap",
3
3
  "homepage": "http://www.whatap.io",
4
- "version": "0.4.51",
5
- "releaseDate": "20220711",
4
+ "version": "0.4.54",
5
+ "releaseDate": "20220718",
6
6
  "description": "Monitoring and Profiling Service",
7
7
  "main": "index.js",
8
8
  "scripts": {},