合并仓库前的准备
This commit is contained in:
parent
c11080a6f6
commit
04eb563794
@ -1,20 +1,20 @@
|
|||||||
# 调试模式
|
# 调试模式
|
||||||
# 1为开启调试
|
# 1为开启调试
|
||||||
DEBUG_MODE=1
|
DEBUG_MODE=1
|
||||||
|
|
||||||
# 爬取数据保存的文件夹
|
# 爬取数据保存的文件夹
|
||||||
# 目录开头与结尾的 [./] [/] [\] [\\] 均可带可不带
|
# 目录开头与结尾的 [./] [/] [\] [\\] 均可带可不带
|
||||||
# 默认为 data 文件夹
|
# 默认为 data 文件夹
|
||||||
DATA_FOLDER=data
|
DATA_FOLDER=data
|
||||||
|
|
||||||
# 是否在程序刚一启动时就抓取一次数据
|
# 是否在程序刚一启动时就抓取一次数据
|
||||||
# 1为是
|
# 1为是
|
||||||
EXECUTE_AT_STARTUP=1
|
EXECUTE_AT_STARTUP=1
|
||||||
|
|
||||||
# 数据是否推送到Git仓库
|
# 数据是否推送到Git仓库
|
||||||
# 1为是
|
# 1为是
|
||||||
PUSH_TO_GIT=0
|
PUSH_TO_GIT=0
|
||||||
|
|
||||||
# 是否仅保存 latest.json 而不保存其他文件作为存档
|
# 是否仅保存 latest.json 而不保存其他文件作为存档
|
||||||
# 1为是
|
# 1为是
|
||||||
LATEST_DATA_ONLY=0
|
LATEST_DATA_ONLY=0
|
16
.gitignore → hotband/.gitignore
vendored
16
.gitignore → hotband/.gitignore
vendored
@ -1,8 +1,8 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
data/*
|
data/*
|
||||||
.env
|
.env
|
||||||
node_modules
|
node_modules
|
||||||
.VSCodeCounter
|
.VSCodeCounter
|
||||||
|
|
||||||
test.js
|
test.js
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ignore": [
|
"ignore": [
|
||||||
".git",
|
".git",
|
||||||
".svn",
|
".svn",
|
||||||
"node_modules/**/node_modules"
|
"node_modules/**/node_modules"
|
||||||
],
|
],
|
||||||
"ext": "js"
|
"ext": "js"
|
||||||
}
|
}
|
2
hotband/pm2 stop.bat
Normal file
2
hotband/pm2 stop.bat
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pm2 stop weibo-hotband-bot
|
||||||
|
pm2 delete weibo-hotband-bot
|
2
hotband/pm2 stop.sh
Normal file
2
hotband/pm2 stop.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pm2 stop weibo-hotband-bot
|
||||||
|
pm2 delete weibo-hotband-bot
|
@ -1,40 +1,40 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
const iconv = require("iconv-lite");
|
const iconv = require("iconv-lite");
|
||||||
|
|
||||||
const encoding = "cp936";
|
const encoding = "cp936";
|
||||||
const bufferEncoding = "binary";
|
const bufferEncoding = "binary";
|
||||||
|
|
||||||
async function execute(rootPath, cmds) {
|
async function execute(rootPath, cmds) {
|
||||||
let outputs = [];
|
let outputs = [];
|
||||||
for (let cmd of cmds) {
|
for (let cmd of cmds) {
|
||||||
let result = await new Promise(function (resolve) {
|
let result = await new Promise(function (resolve) {
|
||||||
// refer: https://www.webhek.com/post/execute-a-command-line-binary-with-node-js/
|
// refer: https://www.webhek.com/post/execute-a-command-line-binary-with-node-js/
|
||||||
child_process.exec(cmd, {
|
child_process.exec(cmd, {
|
||||||
cwd: rootPath, // 脚本执行目录
|
cwd: rootPath, // 脚本执行目录
|
||||||
encoding: bufferEncoding
|
encoding: bufferEncoding
|
||||||
}, function (err, stdout, stderr) {
|
}, function (err, stdout, stderr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve({
|
resolve({
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
err: err,
|
err: err,
|
||||||
// err_stack: iconv.decode(Buffer.from(err.stack, bufferEncoding), encoding),
|
// err_stack: iconv.decode(Buffer.from(err.stack, bufferEncoding), encoding),
|
||||||
// err_message: iconv.decode(Buffer.from(err.message, bufferEncoding), encoding),
|
// err_message: iconv.decode(Buffer.from(err.message, bufferEncoding), encoding),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 获取命令执行的输出
|
// 获取命令执行的输出
|
||||||
resolve({
|
resolve({
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
stdout: iconv.decode(Buffer.from(stdout, bufferEncoding), encoding),
|
stdout: iconv.decode(Buffer.from(stdout, bufferEncoding), encoding),
|
||||||
stderr: iconv.decode(Buffer.from(stderr, bufferEncoding), encoding),
|
stderr: iconv.decode(Buffer.from(stderr, bufferEncoding), encoding),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
outputs.push(result);
|
outputs.push(result);
|
||||||
}
|
}
|
||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.execute = execute;
|
exports.execute = execute;
|
@ -1,2 +0,0 @@
|
|||||||
pm2 stop weibo-hotband-bot
|
|
||||||
pm2 delete weibo-hotband-bot
|
|
@ -1,2 +0,0 @@
|
|||||||
pm2 stop weibo-hotband-bot
|
|
||||||
pm2 delete weibo-hotband-bot
|
|
Loading…
Reference in New Issue
Block a user