Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-transform-runtime"
[
"@babel/preset-env",
{
"targets": {
"node": "18" // 根据你的 Node.js 版本调整
}
}
]
]
}
32 changes: 24 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,41 @@ install_prod:
@clear
@echo "Package installing"
@npm config set registry https://registry.npmmirror.com
@rm -rf package-lock.json
@rm -rf node_modules
@npm install --ignore-scripts
@npm install pm2
@#npm install pm2

# ---- 后面更新这个
install_prod2:
# ---- 后面更新这个 linux用
install_prod_linux:
@clear
@echo "Package installing"
@rm -rf package-lock.json
@rm -rf node_modules
@rm -rf dist
@npm config set registry https://registry.npmmirror.com
@npm install --ignore-scripts
@make -is build # 暂时不编译了
@npm install -g @vercel/ncc --ignore-scripts
@make -is build_linux

# 编译成单个文件
# 编译成单个文件 windows
# https://github.com/vercel/ncc
build:
@# 编译以 ./es6/task.js 入口的相关文件到一个文件里
@clear
@echo "----------- Compile File , please wait...."
@node ./node_modules/@vercel/ncc/dist/ncc/cli.js build ./es6/task.js -m -o ./dist/task
@node ./node_modules/@vercel/ncc/dist/ncc/cli.js build ./es6/www.js -m -o ./dist/www
@echo "----------- Compile success"
@npm run build
@#node ./node_modules/@vercel/ncc/dist/ncc/cli.js build ./es6/task.js -m -o ./dist/task
@#node ./node_modules/@vercel/ncc/dist/ncc/cli.js build ./es6/www.js -m -o ./dist/www
@echo "----------- Compile success"

# 编译成单个文件 linux
# https://github.com/vercel/ncc
build_linux:
@# 编译以 ./es6/task.js 入口的相关文件到一个文件里,这里是把ncc圈布局安装的
@clear
@echo "----linux------- Compile File , please wait...."
@npm run build_linux
@#ncc build ./es6/task.js -m -o ./dist/task
@#ncc build ./es6/www.js -m -o ./dist/www
@echo "----liunx------- Compile success"
51 changes: 0 additions & 51 deletions dist/app/index.js

This file was deleted.

26 changes: 14 additions & 12 deletions dist/task/index.js

Large diffs are not rendered by default.

98 changes: 50 additions & 48 deletions dist/www/index.js

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions docker/apt_image-bak.txt

This file was deleted.

9 changes: 2 additions & 7 deletions docker/ini.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#!/bin/bash

#export TERM=xterm \
#&& apt-get update \
#&& apt-get install supervisor -y \

#cd /app \
#&& make install_prod \
#&& npm install pm2
##&& /usr/bin/supervisord

# 现在外部统一打包好再发布
# 现在外部统一打包好再发布 linux系统需要走这个
cd /app \
&& make install_prod
&& make install_prod_linux

# 赋予权限,方便执行脚本
chmod -R 755 /app/dist
Expand Down
8 changes: 5 additions & 3 deletions docker/unix/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ services:
TZ: Asia/Shanghai
NODE_ENV: production
TERM: xterm
NODE_OPTIONS: '--openssl-legacy-provider'
# 注: windows环境需要开启这个环境变量
#NODE_OPTIONS: '--openssl-legacy-provider'
networks:
default:
ipv4_address: 172.28.0.2
Expand All @@ -26,10 +27,11 @@ services:
# 部署资源限制
deploy:
replicas: 1 # 指定部署数量
# 暂时不限制内存资源了,编译和运行目前放一起的。
resources:
limits: # cpu最大使用数
cpus: '0.8' # 该服务cpu资源可用百分比,单个cpu打满就是 100%, 这里的 1.0 就是 100% 的 意思
memory: 1000M # 主要是编译耗内存:特别是www服务的编译 峰值700~800M,如果只编译 task服务 只需要200M 就够用
cpus: '1.5' # 该服务cpu资源可用百分比,单个cpu打满就是 100%, 这里的 1.0 就是 100% 的 意思
# memory: 1000M # 主要是编译耗内存:特别是www服务的编译 峰值700~800M,如果只编译 task服务 只需要200M 就够用

networks:
default:
Expand Down
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
"version": "3.0.0",
"description": "node_puppeteer_framework",
"main": "gulpfile.js",
"scripts": {
"build:task": "node ./node_modules/@vercel/ncc/dist/ncc/cli.js build ./es6/task.js -m -o ./dist/task ",
"build:www": "node ./node_modules/@vercel/ncc/dist/ncc/cli.js build ./es6/www.js -m -o ./dist/www ",
"build": "npm run build:task && npm run build:www",
"build:task_linux": "ncc build ./es6/task.js -m -o ./dist/task",
"build:www_linux": "ncc build ./es6/www.js -m -o ./dist/www ",
"build_linux": "npm run build:task_linux && npm run build:www_linux"
},
"dependencies": {
"@babel/core": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.8.3",
"@babel/runtime": "^7.8.3",
"@sentry/node": "^6.0.3",
"@sentry/tracing": "^6.0.3",
"@vercel/ncc": "^0.28.6",
"amqplib": "^0.6.0",
"babel-loader": "^8.0.6",
"babelify": "^10.0.0",
"cheerio": "^1.0.0-rc.5",
"crypto-js": "^4.2.0",
Expand All @@ -32,6 +36,7 @@
"mysql2": "^1.6.5",
"node-bugjs": "^2.0.1",
"node-fetch": "^2.6.1",
"pm2": "^5.4.3",
"proxy-http-agent": "^1.0.1",
"puppeteer": "^1.19.0",
"random-useragent": "^0.3.1",
Expand All @@ -42,7 +47,12 @@
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
"sass": "^1.32.2"
"@babel/core": "^7.26.8",
"@babel/preset-env": "^7.26.8",
"@vercel/ncc": "^0.38.3",
"babel-loader": "^9.2.1",
"sass": "^1.32.2",
"webpack": "^5.97.1"
},
"repository": {
"type": "git",
Expand Down