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