total5 0.0.13-4 → 0.0.13-5
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/changelog.txt +2 -0
- package/debug.js +1 -2
- package/index.js +19 -2
- package/package.json +1 -1
- package/pypeline.js +8 -1
- package/viewengine.js +13 -1
package/changelog.txt
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
- added auto script loader for `transforms` directory
|
|
7
7
|
- added support for Python scripts in the `pypelines` folder
|
|
8
8
|
- added `PYPELINE(name, [options])` method starts a python process
|
|
9
|
+
- added support for custom View engine helpers `DEF.helpers.myhelper`
|
|
10
|
+
- fixed killing workers and pypelines
|
|
9
11
|
|
|
10
12
|
========================
|
|
11
13
|
0.0.12
|
package/debug.js
CHANGED
package/index.js
CHANGED
|
@@ -68,6 +68,7 @@ global.DEF = {};
|
|
|
68
68
|
F.errors = [];
|
|
69
69
|
F.paused = [];
|
|
70
70
|
F.crons = [];
|
|
71
|
+
F.pypelines = [];
|
|
71
72
|
|
|
72
73
|
F.internal = {
|
|
73
74
|
ticks: 0,
|
|
@@ -2492,7 +2493,14 @@ F.exit = function(signal = 15) {
|
|
|
2492
2493
|
let worker = F.workers[m];
|
|
2493
2494
|
try {
|
|
2494
2495
|
worker && worker.kill && worker.kill(signal);
|
|
2495
|
-
} catch
|
|
2496
|
+
} catch {}
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
for (let m of F.pypelines) {
|
|
2501
|
+
try {
|
|
2502
|
+
m.kill(signal);
|
|
2503
|
+
} catch {}
|
|
2496
2504
|
}
|
|
2497
2505
|
|
|
2498
2506
|
let key = 'exit';
|
|
@@ -2502,7 +2510,7 @@ F.exit = function(signal = 15) {
|
|
|
2502
2510
|
if (!F.isWorker && process.send && process.connected) {
|
|
2503
2511
|
try {
|
|
2504
2512
|
process.send('total:stop');
|
|
2505
|
-
} catch
|
|
2513
|
+
} catch {}
|
|
2506
2514
|
}
|
|
2507
2515
|
|
|
2508
2516
|
F.internal.interval && clearInterval(F.internal.interval);
|
|
@@ -2778,6 +2786,15 @@ function httptuningperformance(socket) {
|
|
|
2778
2786
|
socket.setKeepAlive(true, 10);
|
|
2779
2787
|
}
|
|
2780
2788
|
|
|
2789
|
+
function forcestop() {
|
|
2790
|
+
console.log('KILLUJEM');
|
|
2791
|
+
F.exit();
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
process.on('SIGTERM', forcestop);
|
|
2795
|
+
process.on('SIGINT', forcestop);
|
|
2796
|
+
process.on('exit', forcestop);
|
|
2797
|
+
|
|
2781
2798
|
process.on('unhandledRejection', function(e) {
|
|
2782
2799
|
F.error(e.stack, '');
|
|
2783
2800
|
});
|
package/package.json
CHANGED
package/pypeline.js
CHANGED
|
@@ -154,15 +154,22 @@ Pypeline.prototype.run = Pypeline.prototype.restart = function() {
|
|
|
154
154
|
args.push(t.filename);
|
|
155
155
|
args.push(t.socket);
|
|
156
156
|
|
|
157
|
-
t.process = Total.Child.spawn('python3', args, { cwd: t.inline ? PATH.root() : Total.Path.dirname(t.filename), stdio: ['inherit', 'inherit', 'inherit'] });
|
|
157
|
+
t.process = Total.Child.spawn('python3', args, { cwd: t.inline ? PATH.root() : Total.Path.dirname(t.filename), stdio: ['inherit', 'inherit', 'inherit'], detached: false });
|
|
158
|
+
t.process.$pypelines = t;
|
|
159
|
+
F.pypelines.push(t.process);
|
|
158
160
|
|
|
159
161
|
t.process.on('close', function() {
|
|
162
|
+
|
|
163
|
+
let index = F.pypelines.indexOf(t.process);
|
|
164
|
+
F.pypelines.splice(index, 1);
|
|
165
|
+
|
|
160
166
|
if (t.autorestart) {
|
|
161
167
|
t.run();
|
|
162
168
|
t.emit('restart');
|
|
163
169
|
} else {
|
|
164
170
|
t.server.close();
|
|
165
171
|
t.emit('close');
|
|
172
|
+
F.pypelines.push(t);
|
|
166
173
|
}
|
|
167
174
|
});
|
|
168
175
|
|
package/viewengine.js
CHANGED
|
@@ -257,7 +257,7 @@ exports.compile = function(name, content, debug = true) {
|
|
|
257
257
|
if (!debug)
|
|
258
258
|
builder = builder.replace(/(\+\$EMPTY\+)/g, '+').replace(/(\$output=\$EMPTY\+)/g, '$output=').replace(/(\$output\+=\$EMPTY\+)/g, '$output+=').replace(/(\}\$output\+=\$EMPTY)/g, '}').replace(/(\{\$output\+=\$EMPTY;)/g, '{').replace(/(\+\$EMPTY\+)/g, '+').replace(/(>'\+'<)/g, '><').replace(/'\+'/g, '');
|
|
259
259
|
|
|
260
|
-
var fn = ('(function(self){var model=self.model;var config=F.config;var ctrl=self.controller;var query=ctrl?.query || EMPTYOBJECT,repository=self.repository,controller=self.controller,files=ctrl?.files || EMPTYARRAY,user=ctrl?.user,session=ctrl?.session,body=ctrl?.body,language=ctrl?.language || \'\'' + (isCookie ? ',cookie=name=>ctrl?ctrl.cookie(name):\'\'' : '') + ';' + (nocompressHTML ? 'if(ctrl)ctrl.response.minify=false;' : '') + builder + ';return $output;})');
|
|
260
|
+
var fn = ('(function(self){var model=self.model;var config=F.config;var ctrl=self.controller;var query=ctrl?.query || EMPTYOBJECT,repository=self.repository,controller=self.controller,files=ctrl?.files || EMPTYARRAY,user=ctrl?.user,session=ctrl?.session,body=ctrl?.body,helpers=F.def.helpers;language=ctrl?.language || \'\'' + (isCookie ? ',cookie=name=>ctrl?ctrl.cookie(name):\'\'' : '') + ';' + (nocompressHTML ? 'if(ctrl)ctrl.response.minify=false;' : '') + builder + ';return $output;})');
|
|
261
261
|
try {
|
|
262
262
|
fn = eval(fn);
|
|
263
263
|
} catch (e) {
|
|
@@ -608,6 +608,18 @@ View.prototype.layout = function(value) {
|
|
|
608
608
|
return '';
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
+
View.prototype.helper = function(name) {
|
|
612
|
+
var helper = F.def.helpers[name];
|
|
613
|
+
if (!helper)
|
|
614
|
+
return '';
|
|
615
|
+
|
|
616
|
+
var params = [];
|
|
617
|
+
for (var i = 1; i < arguments.length; i++)
|
|
618
|
+
params.push(arguments[i]);
|
|
619
|
+
|
|
620
|
+
return helper.apply(this, params);
|
|
621
|
+
};
|
|
622
|
+
|
|
611
623
|
View.prototype.json = function(obj, id, beautify, replacer) {
|
|
612
624
|
|
|
613
625
|
if (typeof(id) === 'boolean') {
|