1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

合并仓库前的准备

This commit is contained in:
程序员小墨 2022-10-17 13:09:59 +08:00
parent c11080a6f6
commit 04eb563794
29 changed files with 78 additions and 78 deletions

View File

@ -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

View File

@ -1,8 +1,8 @@
.DS_Store
data/*
.env
node_modules
.VSCodeCounter
test.js
.DS_Store
data/*
.env
node_modules
.VSCodeCounter
test.js

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -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
View File

@ -0,0 +1,2 @@
pm2 stop weibo-hotband-bot
pm2 delete weibo-hotband-bot

2
hotband/pm2 stop.sh Normal file
View File

@ -0,0 +1,2 @@
pm2 stop weibo-hotband-bot
pm2 delete weibo-hotband-bot

View File

@ -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;

View File

@ -1,2 +0,0 @@
pm2 stop weibo-hotband-bot
pm2 delete weibo-hotband-bot

View File

@ -1,2 +0,0 @@
pm2 stop weibo-hotband-bot
pm2 delete weibo-hotband-bot