@pixui-dev/pxw 0.1.19 → 0.1.21
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/bin/pxw.js +199 -199
- package/bin/wpbuild.js +10 -10
- package/config/default.conf +20 -20
- package/config/devops.js +372 -361
- package/config/h5es.js +10 -10
- package/config/index.html +183 -181
- package/config/pfbs.js +245 -245
- package/config/util.js +140 -140
- package/config/webpack.js +325 -309
- package/lib/assets/check.html +62 -62
- package/lib/assets/preact.js +4354 -4354
- package/lib/check/main.less +62 -62
- package/lib/check/main.tsx +41 -41
- package/lib/check/tool.js +3 -3
- package/lib/check/util.tsx +110 -110
- package/lib/grpc-web/dist/ChunkParser.js +117 -117
- package/lib/grpc-web/dist/Code.js +58 -58
- package/lib/grpc-web/dist/client.js +299 -299
- package/lib/grpc-web/dist/debug.js +16 -16
- package/lib/grpc-web/dist/detach.js +7 -7
- package/lib/grpc-web/dist/index.js +29 -29
- package/lib/grpc-web/dist/invoke.js +32 -32
- package/lib/grpc-web/dist/message.js +3 -3
- package/lib/grpc-web/dist/metadata.js +5 -5
- package/lib/grpc-web/dist/service.js +3 -3
- package/lib/grpc-web/dist/transports/Transport.js +15 -15
- package/lib/grpc-web/dist/transports/http/fetch.js +117 -117
- package/lib/grpc-web/dist/transports/http/http.js +15 -15
- package/lib/grpc-web/dist/transports/http/xhr.js +136 -136
- package/lib/grpc-web/dist/transports/http/xhrUtil.js +36 -36
- package/lib/grpc-web/dist/transports/websocket/websocket.js +95 -95
- package/lib/grpc-web/dist/typings/ChunkParser.d.ts +17 -17
- package/lib/grpc-web/dist/typings/Code.d.ts +20 -20
- package/lib/grpc-web/dist/typings/client.d.ts +25 -25
- package/lib/grpc-web/dist/typings/debug.d.ts +1 -1
- package/lib/grpc-web/dist/typings/detach.d.ts +1 -1
- package/lib/grpc-web/dist/typings/index.d.ts +45 -45
- package/lib/grpc-web/dist/typings/invoke.d.ts +20 -20
- package/lib/grpc-web/dist/typings/message.d.ts +8 -8
- package/lib/grpc-web/dist/typings/metadata.d.ts +2 -2
- package/lib/grpc-web/dist/typings/service.d.ts +16 -16
- package/lib/grpc-web/dist/typings/transports/Transport.d.ts +22 -22
- package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +6 -6
- package/lib/grpc-web/dist/typings/transports/http/http.d.ts +5 -5
- package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +27 -27
- package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +3 -3
- package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +2 -2
- package/lib/grpc-web/dist/typings/unary.d.ts +23 -23
- package/lib/grpc-web/dist/typings/util.d.ts +2 -2
- package/lib/grpc-web/dist/unary.js +44 -44
- package/lib/grpc-web/dist/util.js +11 -11
- package/lib/grpcTransport/PixHttp2Transport.ts +107 -107
- package/lib/grpcTransport/PixLuaTransport.ts +82 -82
- package/lib/h5es-types/v1.9.2/h5es.d.ts +1698 -1698
- package/lib/h5es-types/v3.5.0/h5es.d.ts +1788 -1788
- package/lib/pi_component/tinyList/tinyList.js +483 -483
- package/lib/pi_component/tinyList/tinyList.tsx +517 -517
- package/lib/preact-router.js +395 -395
- package/lib/preact.js +4355 -4355
- package/lib/preact.tq.js +4385 -4385
- package/lib/react-window/src/FixedSizeGrid.js +172 -172
- package/lib/react-window/src/FixedSizeList.js +91 -91
- package/lib/react-window/src/VariableSizeGrid.js +329 -329
- package/lib/react-window/src/VariableSizeList.js +231 -231
- package/lib/react-window/src/__tests__/FixedSizeGrid.js +942 -942
- package/lib/react-window/src/__tests__/FixedSizeList.js +749 -749
- package/lib/react-window/src/__tests__/VariableSizeGrid.js +598 -598
- package/lib/react-window/src/__tests__/VariableSizeList.js +345 -345
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +912 -912
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +568 -568
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +542 -542
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +331 -331
- package/lib/react-window/src/__tests__/areEqual.js +28 -28
- package/lib/react-window/src/__tests__/shouldComponentUpdate.js +32 -32
- package/lib/react-window/src/areEqual.js +13 -13
- package/lib/react-window/src/createGridComponent.js +657 -657
- package/lib/react-window/src/createListComponent.js +574 -574
- package/lib/react-window/src/domHelpers.js +69 -69
- package/lib/react-window/src/index.js +9 -9
- package/lib/react-window/src/shallowDiffers.js +17 -17
- package/lib/react-window/src/shouldComponentUpdate.js +11 -11
- package/lib/react-window/src/test.js.flow +382 -382
- package/lib/react-window/src/timer.js +36 -36
- package/lib/types/dom.ts +17 -17
- package/lib/types/ext.d.ts +81 -81
- package/lib/types/{css.d.ts → preact/css.d.ts} +7476 -7476
- package/lib/types/{preact.d.ts → preact/index.d.ts} +340 -340
- package/lib/types/{internal.d.ts → preact/internal.d.ts} +94 -94
- package/lib/types/{jsx.d.ts → preact/jsx.d.ts} +309 -309
- package/lib/types/preact-router/index.d.ts +85 -0
- package/package.json +113 -113
- package/scripts/pack.js +40 -40
- package/scripts/postinstall.js +11 -11
- package/scripts/run-pxw.js +12 -12
- package/tsconfig.json +30 -30
package/bin/pxw.js
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
let fs = require('fs');
|
|
3
|
-
let cp = require('child_process');
|
|
4
|
-
let path = require('path');
|
|
5
|
-
let http = require('http');
|
|
6
|
-
let os = require('os');
|
|
7
|
-
let util = require('../config/util');
|
|
8
|
-
let pfbs = require('../config/pfbs');
|
|
9
|
-
let webpack = require('../config/webpack');
|
|
10
|
-
let argv = require('yargs').argv;
|
|
11
|
-
|
|
12
|
-
let runInWindows = process.platform == 'win32';
|
|
13
|
-
let pr = path.resolve;
|
|
14
|
-
let log = console.log;
|
|
15
|
-
log = () => {};
|
|
16
|
-
|
|
17
|
-
let rootDir = pr(__dirname, '../');
|
|
18
|
-
let testHtmlDir = pr(__dirname, '../pxtest/html');
|
|
19
|
-
let projectConfig = util.loadProjectConfig();
|
|
20
|
-
let appPort = parseInt(process.env['PXW_APP_PORT']) || projectConfig.port || 8001;
|
|
21
|
-
|
|
22
|
-
let isDaemonMode = argv.d;
|
|
23
|
-
|
|
24
|
-
process
|
|
25
|
-
.on('unhandledRejection', (err) => {
|
|
26
|
-
console.log('unhandledRejection', err);
|
|
27
|
-
})
|
|
28
|
-
.on('uncaughtException', (err) => {
|
|
29
|
-
console.log('uncaughtException', err);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
async function main() {
|
|
33
|
-
let fetch = require('node-fetch');
|
|
34
|
-
let express = require('express');
|
|
35
|
-
let serveIndex = require('serve-index');
|
|
36
|
-
|
|
37
|
-
let app = express();
|
|
38
|
-
let server = http.createServer(app);
|
|
39
|
-
|
|
40
|
-
require('../config/devops').setupDevops(server, app);
|
|
41
|
-
|
|
42
|
-
app.use(express.json());
|
|
43
|
-
app.use(pfbs.getMiddleware());
|
|
44
|
-
app.use(webpack.devServer.getMiddleware()(appPort));
|
|
45
|
-
app.use('/pxtest', serveIndex(testHtmlDir), express.static(testHtmlDir));
|
|
46
|
-
|
|
47
|
-
app.use(function (err, req, res, next) {
|
|
48
|
-
console.error(err);
|
|
49
|
-
res.status(500).send('Internal Serverless Error');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
server.listen(appPort, '0.0.0.0', () => {
|
|
53
|
-
let ipList = [];
|
|
54
|
-
util.getLocalIP().forEach((ip) => {
|
|
55
|
-
console.log(`Server start on http://${ip}:${appPort}`);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//以下处理自动重启和单例
|
|
61
|
-
function restart() {
|
|
62
|
-
const scriptPath = process.argv[1];
|
|
63
|
-
let removeArgs = { '--fg': 1 };
|
|
64
|
-
let args = process.argv.slice(2);
|
|
65
|
-
args = args.filter((v) => !removeArgs[v]);
|
|
66
|
-
const subprocess = cp.spawn(process.execPath, [scriptPath, ...args], {
|
|
67
|
-
detached: true,
|
|
68
|
-
windowsHide: true,
|
|
69
|
-
});
|
|
70
|
-
subprocess.unref();
|
|
71
|
-
process.exit();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function watchSelf() {
|
|
75
|
-
//可以通过环境变量设置是否要监视重启
|
|
76
|
-
let restartWatchFile = process.env['PXW_WATCHFILE'];
|
|
77
|
-
if (restartWatchFile == 'none') return;
|
|
78
|
-
if (!restartWatchFile) restartWatchFile = __filename;
|
|
79
|
-
restartWatchFile = pr(restartWatchFile);
|
|
80
|
-
console.log('watchfile:', restartWatchFile);
|
|
81
|
-
let chokidar = require('chokidar');
|
|
82
|
-
let watcher = chokidar.watch(restartWatchFile, { ignored: /^\./, persistent: true });
|
|
83
|
-
watcher
|
|
84
|
-
.on('change', function (path) {
|
|
85
|
-
console.log(`pid[${process.pid}] observing '${path}' changed, will restart!`);
|
|
86
|
-
restart();
|
|
87
|
-
})
|
|
88
|
-
.on('error', function (error) {
|
|
89
|
-
console.error('watchSelf error:', error);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (isDaemonMode) {
|
|
94
|
-
//默认将log重定向到文件,不然在restart后会丢失
|
|
95
|
-
let logFile = pr(`.cache/app${runInWindows ? '.win' : ''}.log`);
|
|
96
|
-
if (!fs.existsSync(path.dirname(logFile))) fs.mkdirSync(path.dirname(logFile));
|
|
97
|
-
let oldWrite = process.stdout.write.bind(process.stdout);
|
|
98
|
-
var access = fs.createWriteStream(logFile, { flags: 'a' });
|
|
99
|
-
if (!process.env['PXW_NOREDIRECT_LOG']) {
|
|
100
|
-
process.stdout.write = process.stderr.write = access.write.bind(access);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
let checkBinString = 'pxw/bin/pxw.js';
|
|
104
|
-
let checkCmd =
|
|
105
|
-
process.platform == 'win32' //
|
|
106
|
-
? 'wmic /OUTPUT:STDOUT process get processid,commandline'
|
|
107
|
-
: `ps -ef|grep "node"|grep "${checkBinString.replace(/(.)/, '[$1]')}"`; //第一个字符包在[]里可以避免grep命令自身出现在结果里
|
|
108
|
-
|
|
109
|
-
console.log(`\n*** pxw run: ${new Date().toLocaleString()} ***\npid[${process.pid}] check singleton:`, checkCmd);
|
|
110
|
-
cp.exec(checkCmd, { windowsHide: true, maxBuffer: 1024 * 1024 * 10 }, (error, stdout, stderr) => {
|
|
111
|
-
if (error) {
|
|
112
|
-
console.log('pgrep error', error);
|
|
113
|
-
// return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
let cpid = process.pid.toString();
|
|
117
|
-
if (process.platform == 'win32') {
|
|
118
|
-
let psl = stdout.trim().split('\n');
|
|
119
|
-
// console.log(psl.splice(300));
|
|
120
|
-
|
|
121
|
-
for (let cmd of psl) {
|
|
122
|
-
cmd = cmd.replace(/\\/g, '/');
|
|
123
|
-
if ((cmd.indexOf('/node.exe') > 0 || cmd.indexOf('node') == 0) && cmd.indexOf(checkBinString) > 0) {
|
|
124
|
-
let info = cmd.trim().replace(/\s+/g, ' ').split(' ');
|
|
125
|
-
console.log('find', info, process.pid);
|
|
126
|
-
let tpid = info[info.length - 1];
|
|
127
|
-
let isSelf = tpid == cpid;
|
|
128
|
-
console.log(`tpid[${tpid}],isSelf:${isSelf}`);
|
|
129
|
-
if (!isSelf) {
|
|
130
|
-
if (argv.me) {
|
|
131
|
-
cp.execSync('taskkill /F /PID ' + tpid);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
console.log('pgrep stdout\n', stdout);
|
|
142
|
-
let lines = stdout.trim().split('\n');
|
|
143
|
-
for (let line of lines) {
|
|
144
|
-
line = line
|
|
145
|
-
.trim()
|
|
146
|
-
.split(' ')
|
|
147
|
-
.filter((x) => !!x);
|
|
148
|
-
// console.log(line);
|
|
149
|
-
if (line.length > 5) {
|
|
150
|
-
let tpid = line[1];
|
|
151
|
-
let isSelf = tpid == cpid;
|
|
152
|
-
console.log(`tpid[${tpid}],isSelf:${isSelf}`);
|
|
153
|
-
if (tpid && !isSelf) {
|
|
154
|
-
console.log(`found exist process:[${tpid}], cur[${process.pid}]`);
|
|
155
|
-
if ((argv.me || argv.kill) && !error) {
|
|
156
|
-
console.log(`force kill other process:[${tpid}]`);
|
|
157
|
-
try {
|
|
158
|
-
process.stdout.write('', () => {
|
|
159
|
-
cp.execSync('kill ' + tpid);
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
catch (e) {
|
|
163
|
-
console.log(e);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
// cp.execSync('ps -ef|grep test/html/app.js', { stdio: 'inherit' });
|
|
168
|
-
// cp.execSync(`ps -ef|grep ${stdout}`, { stdio: 'inherit' });
|
|
169
|
-
return console.log('process already exist, pid:', tpid);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (argv.kill) return;
|
|
176
|
-
|
|
177
|
-
if (argv.fg || process.env.restart) {
|
|
178
|
-
if (argv.fg) {
|
|
179
|
-
oldWrite(`pid[${process.pid}] run in fg,log已重定向到 ${logFile} \n`);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
let rc = parseInt(process.env.restart);
|
|
183
|
-
process.env.restart = rc + 1;
|
|
184
|
-
console.log(`pid[${process.pid}] run in restart: ${rc}`);
|
|
185
|
-
}
|
|
186
|
-
main();
|
|
187
|
-
watchSelf();
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
console.log(`pid[${process.pid}] run in bg`);
|
|
191
|
-
oldWrite('pxtest-admin 默认后台运行,加--fg参数可前台运行,log已重定向到' + logFile + '\n');
|
|
192
|
-
process.env.restart = 1;
|
|
193
|
-
restart();
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
main();
|
|
199
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
let fs = require('fs');
|
|
3
|
+
let cp = require('child_process');
|
|
4
|
+
let path = require('path');
|
|
5
|
+
let http = require('http');
|
|
6
|
+
let os = require('os');
|
|
7
|
+
let util = require('../config/util');
|
|
8
|
+
let pfbs = require('../config/pfbs');
|
|
9
|
+
let webpack = require('../config/webpack');
|
|
10
|
+
let argv = require('yargs').argv;
|
|
11
|
+
|
|
12
|
+
let runInWindows = process.platform == 'win32';
|
|
13
|
+
let pr = path.resolve;
|
|
14
|
+
let log = console.log;
|
|
15
|
+
log = () => {};
|
|
16
|
+
|
|
17
|
+
let rootDir = pr(__dirname, '../');
|
|
18
|
+
let testHtmlDir = pr(__dirname, '../pxtest/html');
|
|
19
|
+
let projectConfig = util.loadProjectConfig();
|
|
20
|
+
let appPort = parseInt(process.env['PXW_APP_PORT']) || projectConfig.port || 8001;
|
|
21
|
+
|
|
22
|
+
let isDaemonMode = argv.d;
|
|
23
|
+
|
|
24
|
+
process
|
|
25
|
+
.on('unhandledRejection', (err) => {
|
|
26
|
+
console.log('unhandledRejection', err);
|
|
27
|
+
})
|
|
28
|
+
.on('uncaughtException', (err) => {
|
|
29
|
+
console.log('uncaughtException', err);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
async function main() {
|
|
33
|
+
let fetch = require('node-fetch');
|
|
34
|
+
let express = require('express');
|
|
35
|
+
let serveIndex = require('serve-index');
|
|
36
|
+
|
|
37
|
+
let app = express();
|
|
38
|
+
let server = http.createServer(app);
|
|
39
|
+
|
|
40
|
+
let { notifyAppReload } = await require('../config/devops').setupDevops(server, app);
|
|
41
|
+
|
|
42
|
+
app.use(express.json());
|
|
43
|
+
app.use(pfbs.getMiddleware());
|
|
44
|
+
app.use(webpack.devServer.getMiddleware()(appPort, notifyAppReload));
|
|
45
|
+
app.use('/pxtest', serveIndex(testHtmlDir), express.static(testHtmlDir));
|
|
46
|
+
|
|
47
|
+
app.use(function (err, req, res, next) {
|
|
48
|
+
console.error(err);
|
|
49
|
+
res.status(500).send('Internal Serverless Error');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
server.listen(appPort, '0.0.0.0', () => {
|
|
53
|
+
let ipList = [];
|
|
54
|
+
util.getLocalIP().forEach((ip) => {
|
|
55
|
+
console.log(`Server start on http://${ip}:${appPort}`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//以下处理自动重启和单例
|
|
61
|
+
function restart() {
|
|
62
|
+
const scriptPath = process.argv[1];
|
|
63
|
+
let removeArgs = { '--fg': 1 };
|
|
64
|
+
let args = process.argv.slice(2);
|
|
65
|
+
args = args.filter((v) => !removeArgs[v]);
|
|
66
|
+
const subprocess = cp.spawn(process.execPath, [scriptPath, ...args], {
|
|
67
|
+
detached: true,
|
|
68
|
+
windowsHide: true,
|
|
69
|
+
});
|
|
70
|
+
subprocess.unref();
|
|
71
|
+
process.exit();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function watchSelf() {
|
|
75
|
+
//可以通过环境变量设置是否要监视重启
|
|
76
|
+
let restartWatchFile = process.env['PXW_WATCHFILE'];
|
|
77
|
+
if (restartWatchFile == 'none') return;
|
|
78
|
+
if (!restartWatchFile) restartWatchFile = __filename;
|
|
79
|
+
restartWatchFile = pr(restartWatchFile);
|
|
80
|
+
console.log('watchfile:', restartWatchFile);
|
|
81
|
+
let chokidar = require('chokidar');
|
|
82
|
+
let watcher = chokidar.watch(restartWatchFile, { ignored: /^\./, persistent: true });
|
|
83
|
+
watcher
|
|
84
|
+
.on('change', function (path) {
|
|
85
|
+
console.log(`pid[${process.pid}] observing '${path}' changed, will restart!`);
|
|
86
|
+
restart();
|
|
87
|
+
})
|
|
88
|
+
.on('error', function (error) {
|
|
89
|
+
console.error('watchSelf error:', error);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (isDaemonMode) {
|
|
94
|
+
//默认将log重定向到文件,不然在restart后会丢失
|
|
95
|
+
let logFile = pr(`.cache/app${runInWindows ? '.win' : ''}.log`);
|
|
96
|
+
if (!fs.existsSync(path.dirname(logFile))) fs.mkdirSync(path.dirname(logFile));
|
|
97
|
+
let oldWrite = process.stdout.write.bind(process.stdout);
|
|
98
|
+
var access = fs.createWriteStream(logFile, { flags: 'a' });
|
|
99
|
+
if (!process.env['PXW_NOREDIRECT_LOG']) {
|
|
100
|
+
process.stdout.write = process.stderr.write = access.write.bind(access);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let checkBinString = 'pxw/bin/pxw.js';
|
|
104
|
+
let checkCmd =
|
|
105
|
+
process.platform == 'win32' //
|
|
106
|
+
? 'wmic /OUTPUT:STDOUT process get processid,commandline'
|
|
107
|
+
: `ps -ef|grep "node"|grep "${checkBinString.replace(/(.)/, '[$1]')}"`; //第一个字符包在[]里可以避免grep命令自身出现在结果里
|
|
108
|
+
|
|
109
|
+
console.log(`\n*** pxw run: ${new Date().toLocaleString()} ***\npid[${process.pid}] check singleton:`, checkCmd);
|
|
110
|
+
cp.exec(checkCmd, { windowsHide: true, maxBuffer: 1024 * 1024 * 10 }, (error, stdout, stderr) => {
|
|
111
|
+
if (error) {
|
|
112
|
+
console.log('pgrep error', error);
|
|
113
|
+
// return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let cpid = process.pid.toString();
|
|
117
|
+
if (process.platform == 'win32') {
|
|
118
|
+
let psl = stdout.trim().split('\n');
|
|
119
|
+
// console.log(psl.splice(300));
|
|
120
|
+
|
|
121
|
+
for (let cmd of psl) {
|
|
122
|
+
cmd = cmd.replace(/\\/g, '/');
|
|
123
|
+
if ((cmd.indexOf('/node.exe') > 0 || cmd.indexOf('node') == 0) && cmd.indexOf(checkBinString) > 0) {
|
|
124
|
+
let info = cmd.trim().replace(/\s+/g, ' ').split(' ');
|
|
125
|
+
console.log('find', info, process.pid);
|
|
126
|
+
let tpid = info[info.length - 1];
|
|
127
|
+
let isSelf = tpid == cpid;
|
|
128
|
+
console.log(`tpid[${tpid}],isSelf:${isSelf}`);
|
|
129
|
+
if (!isSelf) {
|
|
130
|
+
if (argv.me) {
|
|
131
|
+
cp.execSync('taskkill /F /PID ' + tpid);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.log('pgrep stdout\n', stdout);
|
|
142
|
+
let lines = stdout.trim().split('\n');
|
|
143
|
+
for (let line of lines) {
|
|
144
|
+
line = line
|
|
145
|
+
.trim()
|
|
146
|
+
.split(' ')
|
|
147
|
+
.filter((x) => !!x);
|
|
148
|
+
// console.log(line);
|
|
149
|
+
if (line.length > 5) {
|
|
150
|
+
let tpid = line[1];
|
|
151
|
+
let isSelf = tpid == cpid;
|
|
152
|
+
console.log(`tpid[${tpid}],isSelf:${isSelf}`);
|
|
153
|
+
if (tpid && !isSelf) {
|
|
154
|
+
console.log(`found exist process:[${tpid}], cur[${process.pid}]`);
|
|
155
|
+
if ((argv.me || argv.kill) && !error) {
|
|
156
|
+
console.log(`force kill other process:[${tpid}]`);
|
|
157
|
+
try {
|
|
158
|
+
process.stdout.write('', () => {
|
|
159
|
+
cp.execSync('kill ' + tpid);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
console.log(e);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// cp.execSync('ps -ef|grep test/html/app.js', { stdio: 'inherit' });
|
|
168
|
+
// cp.execSync(`ps -ef|grep ${stdout}`, { stdio: 'inherit' });
|
|
169
|
+
return console.log('process already exist, pid:', tpid);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (argv.kill) return;
|
|
176
|
+
|
|
177
|
+
if (argv.fg || process.env.restart) {
|
|
178
|
+
if (argv.fg) {
|
|
179
|
+
oldWrite(`pid[${process.pid}] run in fg,log已重定向到 ${logFile} \n`);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
let rc = parseInt(process.env.restart);
|
|
183
|
+
process.env.restart = rc + 1;
|
|
184
|
+
console.log(`pid[${process.pid}] run in restart: ${rc}`);
|
|
185
|
+
}
|
|
186
|
+
main();
|
|
187
|
+
watchSelf();
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
console.log(`pid[${process.pid}] run in bg`);
|
|
191
|
+
oldWrite('pxtest-admin 默认后台运行,加--fg参数可前台运行,log已重定向到' + logFile + '\n');
|
|
192
|
+
process.env.restart = 1;
|
|
193
|
+
restart();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
main();
|
|
199
|
+
}
|
package/bin/wpbuild.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
|
|
3
|
-
let config = require('../config/webpack');
|
|
4
|
-
webpack(config, (err, stats) => {
|
|
5
|
-
if (err || stats.hasErrors()) {
|
|
6
|
-
console.log(err);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
console.log('done');
|
|
10
|
-
});
|
|
1
|
+
const webpack = require('webpack');
|
|
2
|
+
|
|
3
|
+
let config = require('../config/webpack');
|
|
4
|
+
webpack(config, (err, stats) => {
|
|
5
|
+
if (err || stats.hasErrors()) {
|
|
6
|
+
console.log(err);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
console.log('done');
|
|
10
|
+
});
|
package/config/default.conf
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
server {
|
|
2
|
-
|
|
3
|
-
listen 80;
|
|
4
|
-
server_name localhost;
|
|
5
|
-
|
|
6
|
-
location / {
|
|
7
|
-
rewrite ^/$ /web/home/;
|
|
8
|
-
rewrite ^/home/(.*)$ /web/home/$1;
|
|
9
|
-
rewrite ^/static/media/(.*)$ /web/static/media/$1;
|
|
10
|
-
|
|
11
|
-
root /usr/share/nginx/html;
|
|
12
|
-
index index.html index.htm;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
error_page 500 502 503 504 /50x.html;
|
|
17
|
-
location = /50x.html {
|
|
18
|
-
root /usr/share/nginx/html;
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
server {
|
|
2
|
+
|
|
3
|
+
listen 80;
|
|
4
|
+
server_name localhost;
|
|
5
|
+
|
|
6
|
+
location / {
|
|
7
|
+
rewrite ^/$ /web/home/;
|
|
8
|
+
rewrite ^/home/(.*)$ /web/home/$1;
|
|
9
|
+
rewrite ^/static/media/(.*)$ /web/static/media/$1;
|
|
10
|
+
|
|
11
|
+
root /usr/share/nginx/html;
|
|
12
|
+
index index.html index.htm;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
error_page 500 502 503 504 /50x.html;
|
|
17
|
+
location = /50x.html {
|
|
18
|
+
root /usr/share/nginx/html;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
21
|
}
|