total5 0.0.1-1

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.
Files changed (57) hide show
  1. package/503.html +65 -0
  2. package/CONTRIBUTING.md +55 -0
  3. package/LICENSE +211 -0
  4. package/README.md +32 -0
  5. package/api.js +289 -0
  6. package/bin/total5 +984 -0
  7. package/builders.js +1435 -0
  8. package/bundles.js +457 -0
  9. package/cache.js +58 -0
  10. package/changelog.txt +3 -0
  11. package/cluster.js +320 -0
  12. package/cms.js +625 -0
  13. package/controller.js +1419 -0
  14. package/cron.js +99 -0
  15. package/debug.js +539 -0
  16. package/edit.js +469 -0
  17. package/error.html +49 -0
  18. package/filestorage.js +1088 -0
  19. package/flow-flowstream.js +3152 -0
  20. package/flow.js +209 -0
  21. package/flowstream.js +1991 -0
  22. package/global.js +125 -0
  23. package/helpers/index.js +32 -0
  24. package/htmlparser.js +650 -0
  25. package/http.js +81 -0
  26. package/image.js +773 -0
  27. package/images.js +747 -0
  28. package/index.js +2658 -0
  29. package/jsonschema.js +691 -0
  30. package/ldap.js +792 -0
  31. package/mail.js +936 -0
  32. package/minificators.js +858 -0
  33. package/nosql-builder.js +440 -0
  34. package/nosql-querybuilder.js +316 -0
  35. package/nosql-reader.js +353 -0
  36. package/nosql-stream.js +617 -0
  37. package/nosql.js +763 -0
  38. package/openclient.js +219 -0
  39. package/package.json +32 -0
  40. package/pause.html +67 -0
  41. package/querybuilder.js +1361 -0
  42. package/release.js +167 -0
  43. package/routing.js +905 -0
  44. package/sourcemap.js +160 -0
  45. package/tangular.js +409 -0
  46. package/templates.js +145 -0
  47. package/templates.json +74 -0
  48. package/tms.js +384 -0
  49. package/tmsclient.js +125 -0
  50. package/todo.txt +7 -0
  51. package/tools/beta.sh +6 -0
  52. package/tools/release.sh +6 -0
  53. package/uibuilder.js +206 -0
  54. package/utils.js +6374 -0
  55. package/viewengine.js +880 -0
  56. package/websocket.js +1939 -0
  57. package/workers.js +129 -0
package/release.js ADDED
@@ -0,0 +1,167 @@
1
+ require('./index');
2
+
3
+ // Variables
4
+ var WATCHER = process.connected === true;
5
+ var options;
6
+ var app;
7
+ var firstinit = true;
8
+ var pidname;
9
+ var unexpectedexit = false;
10
+ var restarting;
11
+
12
+ module.exports = function(opt) {
13
+
14
+ options = opt || {};
15
+
16
+ // options.ip = '127.0.0.1';
17
+ // options.port = parseInt(process.argv[2]);
18
+ // options.unixsocket = require('node:path').join(require('node:os').tmpdir(), 'app_name');
19
+ // options.config = { name: 'Total.js' };
20
+ // options.https = { key: Fs.readFileSync('keys/agent2-key.pem'), cert: Fs.readFileSync('keys/agent2-cert.pem')};
21
+ // options.sleep = 3000;
22
+ // options.inspector = 9229;
23
+ // options.debugger = 40894;
24
+ // options.watch = ['adminer'];
25
+ // options.livereload = true;
26
+ // options.watcher = false;
27
+ // options.cluster = 'auto' || or NUMBER
28
+ // options.limit = 10;
29
+ // options.timeout = 5000;
30
+ // options.edit = 'wss://.....com/?id=myprojectname'
31
+
32
+ if (!WATCHER)
33
+ WATCHER = process.argv.indexOf('--watcher') === -1 && !options.watcher;
34
+
35
+ };
36
+
37
+ function makestamp() {
38
+ return '--- # --- [ ' + new Date().format('yyyy-MM-dd HH:mm:ss') + ' ] ';
39
+ }
40
+
41
+ function restart() {
42
+ restarting && clearTimeout(restarting);
43
+ restarting = setTimeout(run, 100);
44
+ }
45
+
46
+ function run() {
47
+
48
+ restarting = null;
49
+
50
+ var arr = F.TUtils.clone(process.argv).slice(2);
51
+ var port = arr.pop();
52
+ var directory = process.cwd();
53
+
54
+ if (!firstinit)
55
+ arr.push('--restart');
56
+
57
+ port && arr.push(port);
58
+ var filename = F.TUtils.getName(process.argv[1] || 'index.js');
59
+
60
+ pidname = F.Path.join(directory, filename.replace(/\.js$/, '.pid'));
61
+ app = F.Fork(F.Path.join(process.cwd(), filename), arr);
62
+ app.on('message', function(msg) {
63
+ switch (msg) {
64
+ case 'total:eaddrinuse':
65
+ process.exit(1);
66
+ break;
67
+ case 'total:ready':
68
+ if (firstinit) {
69
+ app.send('total:debug');
70
+ firstinit = false;
71
+ }
72
+ break;
73
+ case 'total:restart':
74
+ console.log(makestamp().replace('#', 'RES'));
75
+ unexpectedexit = true;
76
+ setTimeout(restart, 1000);
77
+ process.kill(app.pid);
78
+ app = null;
79
+ break;
80
+ }
81
+ });
82
+
83
+ F.Fs.writeFileSync(pidname, process.pid + '');
84
+
85
+ app.on('exit', function() {
86
+
87
+ // checks unexpected exit
88
+ if (unexpectedexit === true)
89
+ app = null;
90
+ else
91
+ restart();
92
+
93
+ unexpectedexit = false;
94
+ });
95
+
96
+ EMIT('watcher', app);
97
+ }
98
+
99
+ function init() {
100
+
101
+ if (options.cluster) {
102
+ options.release = true;
103
+ options.count = options.cluster;
104
+ F.TCluster.http(options);
105
+ return;
106
+ }
107
+
108
+ if (WATCHER) {
109
+
110
+ delete options.watcher;
111
+
112
+ if (options.servicemode) {
113
+ var types = options.servicemode === true || options.servicemode === 1 ? '' : options.servicemode.split(',').trim();
114
+ global.DEBUG = false;
115
+ F.load(types);
116
+ if (!process.connected)
117
+ F.console();
118
+ } else {
119
+ global.DEBUG = false;
120
+ F.http(options);
121
+ }
122
+ return;
123
+ }
124
+
125
+ var end = function() {
126
+
127
+ if (process.isending)
128
+ return;
129
+
130
+ process.isending = true;
131
+ F.Fs.unlink(pidname, NOOP);
132
+
133
+ if (app) {
134
+ unexpectedexit = true;
135
+ process.kill(app.pid);
136
+ app = null;
137
+ }
138
+
139
+ process.exit(0);
140
+ };
141
+
142
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1';
143
+ console.log('-------- RELEASE PID: ' + process.pid + ' (v' + F.version_header + ')');
144
+ process.on('uncaughtException', e => e.toString().indexOf('ESRCH') == -1 && console.log(e));
145
+ process.title = 'total: release';
146
+ process.on('SIGTERM', end);
147
+ process.on('SIGINT', end);
148
+ process.on('exit', end);
149
+
150
+ setInterval(function() {
151
+ F.Fs.stat(pidname, function(err) {
152
+ if (err) {
153
+ unexpectedexit = true;
154
+ process.kill(app.pid);
155
+ setTimeout(() => process.exit(0), 100);
156
+ }
157
+ });
158
+ }, 4000);
159
+
160
+ if (!process.connected && options.edit) {
161
+ require('./edit').init(options.edit.replace(/^http/, 'ws'));
162
+ setTimeout(run, 1000);
163
+ } else
164
+ setImmediate(run);
165
+ }
166
+
167
+ setTimeout(init, 50);