00

不存在完美的GC

GC停顿时间比较

关注点

衡量垃圾收集器的三项最重要的指标是:内存占用(Footprint)、吞吐量(Throughput)和延迟(Latency),三者共同构成了一个“不可能三角”。

找到垃圾

引用计数

  • 循环引用问题
    • C++ 智能指针

可达性分析

  • GC Root

    • 在虚拟机栈(栈帧中的本地变量表)中引用的对象
    • 在方法区中类静态属性引用的对象
    • 在方法区中常量引用的对象
    • 在本地方法栈中JNI引用的对象
    • Java虚拟机内部的引用,如基本数据类型对应的Class对象
    • 所有被同步锁(synchronized关键字)持有的对象
    • 反映Java虚拟机内部情况的JM XBean、JVM TI中注册的回调、本地代码缓存等
  • 非死不可

    • finalize()
    • 虽然有但是不推荐使用
  • 并发可达性分析:三色标记

    • 并发扫描时的对象消失问题
      • 增量更新(Incremental Update)
      • 原始快照(Snapshot At The Beginning, SATB)
    • 浮动垃圾

如何回收

分代收集理论

  • 弱分代假说(Weak Generational Hypothesis):绝大多数对象都是朝生夕灭的。
  • 强分代假说(Strong Generational Hypothesis):熬过越多次垃圾收集过程的对象就越难以消亡。
  • 跨代引用假说(Intergenerational Reference Hypothesis):跨代引用相对于同代引用来说仅占极少数。

但是也有反例或者说不使用这个理论的对象:缓存(LRU)

算法

  • 标记-清除算法
  • 标记-复制算法
  • 标记-整理算法

流程

  • 根结点枚举
    • 必须STW
    • 安全点
      • 抢先式中断
      • 主动式中断
    • 安全区域:安全点的扩展

记忆集与卡表

为解决对象跨代引用所带来的问题,垃圾收集器在新生代中建立了名为记忆集(Remembered Set)的数据结构,用以避免把整个老年代加进GC Roots扫描范围

  • 如何维护
    • 写屏障

垃圾收集器

  • Serial收集器
    • 单线程
  • Serial Old收集器
    • 老年代版本
  • ParNew收集器
    • Serial的多线程版本
  • Parallel Old收集器
    • 老年代版本
  • Parallel Scavenge收集器
    • 关注吞吐量
    • 自适应调节策略
  • CMS收集器
    • 以获取最短回收停顿时间为目标的收集器
    • CMS收集器对处理器资源非常敏感
    • CMS收集器无法处理“浮动垃圾”
    • 大量空间碎片产生
  • Garbage First收集器
    • 基于Region的内存布局形式
    • 能够建立起“停顿时间模型”(Pause Prediction M odel)的收集器
    • 追求能够应付应用的内存分配速率(吞吐率优先)
  • Shenandoah收集器
    • 在任何堆内存大小下都可以把垃圾收集的停顿时间限制在十毫秒以内的垃圾收集器
  • ZGC收集器
    • 在尽可能对吞吐量影响不太大的前提下,实现在任意堆内存大小下都可以把垃圾收集的停顿时间限制在十毫秒以内的低延迟

G1GC

  • 极易调整,只需要设定最大停顿时间(默认200ms)
  • 混合GC(Mixed GC)
  • 在满足吞吐量的情况下尽可能少的GC
  • 写屏障,脏卡队列,使用细分线程来更新记忆集(remember set)
  • 避免full gc
  • 避免大对象分配
  • eden区会因为混合GC缩小,需要关注应用程序线程利用率

Shenandoah GC

SATB屏障(buffer)和两段并发标记

实现并发拷贝的技术点:指针引用转发

ZGC

ZGC设计:

指针染色(colored pointers)

GC阶段STW过程:

堆外表维护引用 like 指针引用转发

线程本地握手

经典技术回顾

cpu设计历史

  • 流水线 ILP
  • 功耗
  • 存储系统结构设计
  • 向量 SIMD GPU 大数据流并行结构
  • 互联网数据中心
  • 移动计算
  • 面向领域硬件

体系结构经典技术

  • 流水线
  • 动态调度
  • Cache
  • 向量机
  • RISC
  • 多发射 乱序执行
  • EPIC
  • SMT 同时多线程
  • CMP 片上多核

性能参数计算

  • 程序执行时间 = 指令 x(周期/指令)x(时间/周期):并不独立 互相相关
    • IC x CPI x CCT
    • CPI = base + stalls
  • 功耗 = 动态功耗 (电容 x 电压 x 主频)+ 静态功耗 (漏电流功耗)

CPU指令类型

  • logical
  • loads store
  • control flow

现代处理器核设计技术基础

  • Pipelines
    • 5级流水线 MIPS R3000
    • 优点 提高主频
    • 缺点 长短指令时间一致 导致停滞
      • 改进: 更深的流水线
      • 更宽的流水线 超标量流水线
      • 切分流水线
      • 乱序执行
      • 分支预测
    • 限制
      • 流水线寄存器延迟
      • 每个阶段不对等
      • 时钟漂移
      • 57级之后没有收益(功耗爆增)
    • Amdahl’s Law
  • Branch Prediction
    • BHT 转移历史表 + 译码
    • BTB 转移目标缓冲器
  • Register Renaming
    • tomasulo algorithm
  • Out-of-Order Execution
  • Re-order Buffer
  • Data Parallel Processing SIMD / Vector Extensions

存储系统设计:高速缓存

存储层次结构:

  • 寄存器
    • 逻辑寄存器
    • 物理寄存器
  • Cache TLB
    • why: memory wall
    • 经典组织结构
      • 三级缓存
    • 操作策略
      • 放置
        • 全关联
        • 直接映射
        • 多路组关联
      • 识别
        • 低位index(增加辨识度) 高位tag
      • 替换
        • LRU
        • RAND
        • FIFO
      • 写策略
        • 写通过
        • 写回
    • 性能 AMAT
      • 降低缺失率
        • 必然缺失 冷启动缺失
        • 容量缺失 -> 增加块大小
        • 冲突缺失 -> 提高关联度
        • 一致性缺失(多核)
    • 功耗
  • Memory
  • Disk
  • 网络存储

局部性原理:存储层次结构的基础

  • 时间局部性
  • 空间局部性

高速缓存优化策略

  • multi-level cache 多级cache
    • 针对每级cache做不同的优化
  • victim cache
    • 使用小cache保存L1丢弃的数据
  • pseudo-associative cache 伪关联
    • cache分块 猜测多次(猜测预测)
    • 缺陷 流水线难设计 猜测算法难设计
  • skew-associative cache 斜关联
    • 每路cache使用不同的index hashing
    • 缺点 hash函数延迟
  • non-blocking cache
    • 缺失发生时继续提供命中
  • critical word first 关键字优先
    • 优先发送缺失的字
  • prefetching
    • 硬件预取
    • 软件预取
  • multi-ported cache

优化方向

  • 降低缺失率
  • 降低缺失损失
  • 降低cache命中时间
    • 片上多级cache
    • 加速地址翻译
    • cache访问流水线

存储系统设计:主存储器

没有miss rate 只关注命中时间
操作类型:

  • LD/ST
  • DMA(直接内存访问)

RAM:

  • SRAM 用于L1/L2 cache
  • DRAM 用于主存

Memory Bank:

  • 解码读取一行
  • 选中行
  • 读取某些列
  • 输出
  • 回填数据

memory access:

  • active
  • read
  • write
  • precharge
  • refresh

burst:

  • 每次读多列
  • channel时钟比核心快

时序约束

  • tRCD 打开行读到行放大器时间
  • tCAS 打开一列到数据选出
  • tCCD 两次列命令时间间隔
  • tRP precharge时间
  • tRAS 行保持开放的时间
  • tRC 行的周期时间 = tRP + tRAS 访问不同行的最小时间间隔

rank: 片选bank
channels: 内存通道
NUMA topology: non-uniform memory access
DRAM controller 功能:

  • 翻译请求到dram命令
  • 缓存和调度请求
  • 保证操作正确(刷新)
  • 管理功耗

flash storage

是一种非易失存储器
是EPROM和EEPROM的升级产品
分类:

  • NAND
  • NOR

ISA tradeoffs

提供给程序员使用的指令集合
design point:

  • leads to tradeoff in both ISA and uarch
  • cost
  • performance
  • maximum power consumption
  • energy consumption
  • availability
  • reliability and correctness
  • time to market

soul of computer architecture:

  • ISA level tradeoff
  • 微体系结构权衡
  • 系统和任务级权衡

different ISA:

  • x86
  • PDP
  • VAX
  • IBM 360
  • CDC 6600
  • SIMD
  • VLIW
  • Power PC
  • RISC: alpha MIPS SPARC ARM

instruction:

  • basic element of HW/SW interface
  • 构成:
    • 操作码
    • 操作数

elements of ISA:

  • sequencing model
    • control flow vs data flow
  • processing style:
    • number of operands an instruction operates
    • 0,1,2,3 address machines
      • 0 stack machine
      • 1 accumulator machine
      • 2 2-operand machine
      • 3 3-operand machine
  • instructions
    • opcode
    • operand specifiers (addressing modes)
  • data types
    • definition
    • integer floating point
    • doubly linked list, queue, string, bit,vector
  • memory organization
    • address space
    • addressability
      • byte
      • bit
      • 64-bit
      • 32-bit
    • support for virtual memory
  • registers
    • how many
    • size of each register
  • load/store vs memory/memory
  • addressing modes
    • absolute
    • register indirect
    • displaced or based
    • indexed
    • memory indirect
    • auto inc/dec
  • how to interface with I/O devices
    • memory mapped I/O
    • special I/O instructions
  • privilege modes
    • user
    • supervisor
  • exception and interrupt handling
  • virtual memory
  • access protection
  • instruction length
    • fixed length
    • variable length
  • uniform decode
    • uniform
    • non-uniform
  • number of registers
  • addressing mode

availability & reliability

reliability:

  • MTTF: mean time to failure
  • MTTR: mean time to repair
  • MTBF = MTTF + MTTR

availability = MTTF / (MTTF + MTTR)
types of faults:

  • hardware
  • software
  • operator errors
  • environment factors
  • security breaches
  • planned service events

performance engineering

steps:

  • measurement
  • analysis
  • improvements
  • repeat

performance:

  • IPC
  • IPS
  • QPS
  • execution time
  • AMAT: average memory access latency
  • fairness,priorities

power:

  • watts
  • instructions

evaluation choices:

  • real experiments
  • using analytical models
  • using a simulator

on-chip networks

shift to multicore 单核很难提升
amdahl law:串行部分影响加速比
design:

  • topology
    • bus 总线
    • crossbar 交叉开关网
  • flow control
    • messages,packets,flits,phits
    • bufferless
      • circuit switching
      • dropping
      • misrouting
    • buffered
      • store and forward
      • virtual cut through
      • wormhole
      • virtual channel
  • router microarchitecture
  • routing
    • deterministic
    • adaptive
    • minimal
    • deadlock free

cache coherence

communication models

  • shared memory
  • message passing

implementing
tow rules:

  • write propagation 写传播
  • write serialization 写顺序 有顺序且所有处理器都看到同一顺序

如何保证写传播

  • 写无效
  • 写更新

跟踪缓存状态和序列化

  • 基于侦听
    • VI协议
    • MSI协议
    • MESI协议
    • MOSI
    • MOESI
  • 基于目录

memory consistency

顺序一致性模型
松散一致性模型:

  • load 越过 load
  • load 越过 store
  • 允许store乱序执行
  • store越过load

单核优化技术在多核存储一致性上遇到的问题:

  • store buffer
  • store lod bypassing
  • non FIFO store buffers
  • non blocking caches
  • register renaming
  • speculative execution 推测执行
  • address speculation 地址推测
  • store atomicity
  • causality

弱一致性模型 + 内存保护指令

超算

GPU

领域特定架构

前言

许久没有折腾博客了,就借着双11买了台国内服务器建站的时机来水一篇,恢复一下节奏。因为很久没用才发现之前用的Travis CI已经不知道因为什么原因触发不了了,就正好也折腾一下,换成了Github Action。

Github Action

鉴于之前根本没有接触过Github Action的写法,所以解决问题的核心就是找几个例子看一下,然后看看怎么改装现有的CI脚本。

copy from

这里借鉴的是如何使用Github+Actions实现Hexo博客自动化部署里的CI yml配置文件。主要的变化也就是Secret的语法稍微有点不同,变成了

1
${{ secrets.TRAVIS_CI }}

而且也不知道为什么之前配置的Secret过期了就重新配置了一个,然后就把之前的shell直接搬运到RUN里,加入之前安装的插件就OK了。

快速搭建服务器

双11薅了TX云三年服务器的羊毛,然后买了个域名,计划着把之前一部分在HK服务器上和树莓派上的服务都整到国内的服务器上,一是访问速度更快,二是比家里的树梅派更稳定一点(老是断电)。由于之前用Docker Compose搭建了一部分的服务感觉很方便,所以就计划这次的服务器上所有的服务都基于Docker和Docker Compose来搭建。

composerize

网页版

一个用来转换docker run命令到Compose文件的工具,如果官方的docker镜像没有给出compose的话就用这个做一下转化,省的自己慢慢写了。

Portainer

因为计划全部用Docker来搭建,所以就选择了一个Docker的Web管理工具,后面的全部应用都基于Portainer的Compose功能来启动和管理了。

启动

直接使用官方的命令:

1
2
3
4
5
6
7
8
9
docker volume create portainer_data
docker run -d \
-p 8000:8000 \
-p 9000:9000 \
--name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
cr.portainer.io/portainer/portainer-ce

先启动项目然后开启服务器的9000端口用来临时访问(后面再关掉)。

bunkerized-nginx

这是一个自带TLS证书签发续签的Nginx镜像,正好省了自己去配置续签定时任务的功夫就直接用上了。在Portainer的Stack里直接创建一个Stack:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
version: '3'
services:
mybunkerized:
image: bunkerity/bunkerized-nginx
ports:
- 80:8080
- 443:8443
volumes:
# - /bilibifun.cn/www:/www:ro
- /bilibifun.cn/certs:/etc/letsencrypt
- /bilibifun.cn/server-confs:/server-confs
- /bilibifun.cn/modsec-crs-confs:/modsec-crs-confs
environment:
- SERVE_FILES=no
- SERVER_NAME=www.bilibifun.cn
- AUTO_LETS_ENCRYPT=yes
- USE_REVERSE_PROXY=yes
# - PROXY_REAL_IP=yes
- DISABLE_DEFAULT_SERVER=yes
- REDIRECT_HTTP_TO_HTTPS=yes
- REVERSE_PROXY_WS=yes
- USE_BAD_BEHAVIOR=no
- USE_LIMIT_REQ=no
- REVERSE_PROXY_KEEPALIVE=yes
- BLOCK_USER_AGENT=no
- ALLOWED_METHODS=GET|POST|HEAD|PROPFIND|DELETE|PUT|MKCOL|MOVE|COPY|PROPPATCH|REPORT
- USE_MODSECURITY=no

关于voluems里的certs的文件夹映射一定一定一定要看一下官方文档,因为有一定的文件权限问题(反正先看看官方Start肯定没有错)。modsec-crs-confs和下面一堆的配置是之前折腾Bitwarden的时候搞的,现在也不知道哪些是一定要配置的,建议先从最简单的配置出发然后逐渐改成能用的就行。USE_MODSECURITY这个配置项是安全相关的,建议在网站调试期间先关掉,不然会触发主动BAN IP的功能。

server-confs

这个就是配置location转发的地方了,因为只签了www的二级域名,所以后面全部的功能的反向代理都用baseUrl的方式来进行。配置的时候就直接往里面丢conf就行

server-confs/portainer.conf

先给portainer配上。不过因为修改server-conf都需要重启nginx,所以可以等最后再用域名形式访问。

1
2
3
4
5
6
7
location /portainer/ {
proxy_pass http://172.17.0.1:9000;
rewrite ^/portainer/(.*) /$1 break;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

v2rayA

建于某些不可知的原因,TTRSS里的有些订阅源需要进行特殊处理,所以在搭建ttrss之前就需要先整个这玩意儿了。

1
2
3
4
5
6
7
8
9
10
11
12
13
version: '3'
services:
v2raya:
privileged: false
network_mode: host
container_name: v2raya
environment:
- 'V2RAYA_ADDRESS=0.0.0.0:9002'
volumes:
- '/lib/modules:/lib/modules'
- '/etc/resolv.conf:/etc/resolv.conf'
- '/etc/v2raya:/etc/v2raya'
image: mzz2017/v2raya

由于不使用host模式配置过于复杂,这里就直接给整成host模式了,当然最好Docker还是不要使用host模式。。

server-confs/v2raya.conf

1
2
3
4
5
6
7
8
location /v2raya/ {
proxy_pass http://172.17.0.1:9002/;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

只代理了web页面,因为暴露的socks5端口只在本地使用,就没有关系了。

TTRSS

当然这玩意儿才是最核心的了,但是在Awesome-TTRSS这个项目的加持之下,ttrss的安装已经变得非常简单了,直接拿文档里的Compose文件来改改就行。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
version: "3"
services:
service.rss:
image: wangqiru/ttrss:latest
container_name: ttrss
ports:
- 9001:80
environment:
- SELF_URL_PATH=https://www.bilibifun.cn #这里虽然是baseUrl但还是只要填域名就好
- DB_PASS=AAAAAAAAAA # use the same password defined in `database.postgres`
- PUID=1000
- PGID=1000
- SESSION_COOKIE_LIFETIME=720 # 增加session时长
- HTTP_PROXY=172.17.0.1:20171 # 这里就是神秘软件的端口了
volumes:
- feed-icons:/var/www/feed-icons/
networks:
- public_access
- service_only
- database_only
stdin_open: true
tty: true

service.mercury: # set Mercury Parser API endpoint to `service.mercury:3000` on TTRSS plugin setting page
image: wangqiru/mercury-parser-api:latest
container_name: mercury
networks:
- public_access
- service_only

service.opencc: # set OpenCC API endpoint to `service.opencc:3000` on TTRSS plugin setting page
image: wangqiru/opencc-api-server:latest
container_name: opencc
environment:
- NODE_ENV=production
networks:
- service_only

database.postgres:
image: postgres:13-alpine
container_name: postgres
environment:
- POSTGRES_PASSWORD=AAAAAAAAAA # feel free to change the password
volumes:
- ttrss_postgres:/var/lib/postgresql/data # persist postgres data to ~/postgres/data/ on the host
networks:
- database_only

volumes:
feed-icons:
ttrss_postgres:

networks:
public_access: # Provide the access for ttrss UI
service_only: # Provide the communication network between services only
internal: true
database_only: # Provide the communication between ttrss and database only
internal: true

server-confs/ttrss.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
location /ttrss/ {
rewrite /ttrss/(.*) /$1 break;
proxy_redirect https://$http_host https://$http_host/ttrss;
proxy_pass http://172.17.0.1:9001;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;

client_max_body_size 100m;
client_body_buffer_size 128k;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}

这个就直接按照官网的配置来就行,只是网页上有些功能还是不能正常使用,比如点标题的链接会404 = =。

RSSHUB

这个也很简单,官方文档有Compose文件,直接用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
version: '3'

services:
rsshub:
image: diygod/rsshub
ports:
- '9003:1200'
environment:
NODE_ENV: production
CACHE_TYPE: redis
REDIS_URL: 'redis://redis:6379/'
PUPPETEER_WS_ENDPOINT: 'ws://browserless:3000'
depends_on:
- redis
- browserless

browserless:
# See issue 6680
image: browserless/chrome:1.43-chrome-stable
ulimits:
core:
hard: 0
soft: 0

redis:
image: redis:alpine
volumes:
- redis-data:/data

volumes:
redis-data:

rsshub.conf

1
2
3
4
5
6
7
8
location /rsshub/ {
proxy_pass http://172.17.0.1:9003/;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

Bitwarden

这个也是官方有Compose,拿来直接用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: "3"

services:
bitwarden:
image: vaultwarden/server
container_name: bitwarden-server
ports:
- "9004:80"
- "9005:3012"
volumes:
- bitwarden:/data
environment:
WEBSOCKET_ENABLE: "true"
SIGNUPS_ALLOWED: "true"
WEB_VAULT_ENABLE: "true"
DOMAIN: "https://bilibifun.cn/bitwarden"
ADMIN_TOKEN: "AAAAAAAAAAA"
volumes:
bitwarden:

bitwarden.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
location /bitwarden/ {
proxy_pass http://172.17.0.1:9004;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /bitwarden/notifications/hub {
proxy_pass http://172.17.0.1:9005;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location /bitwarden/notifications/hub/negotiate {
proxy_pass http://172.17.0.1:9004;
}

这个似乎也是官方给出的配置,直接拿来用就行。

NPS

用来穿透一下树莓派,挂一下WEBDAV用的。

1
2
3
4
5
6
7
8
9
10
11
version: '3.3'
services:
nps:
container_name: nps
ports:
- '9009:8024'
- '9010:8080'
- '10000-10020:10000-10020'
volumes:
- '/root/conf:/conf'
image: ffdfgdfg/nps

nps.conf

1
2
3
4
5
6
location /nps/ {
proxy_pass http://172.17.0.1:9010;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

VuePress

因为网站还是缺个首页,所以就打算用vuepress整一个试试水,本来是打算给博客直接从hexo搬到vuepress的,但是现在vuepress-next还没有很多主题跟进,就还是先用官方默认的搭一下首页就行。大致看了下官方文档,然后找了篇1小时搞定vuepress快速制作vue文档/博客+免费部署预览直接拷贝一下,因为现在还没有内容,只是搞个首页然后给其他工具做个导航,就只做了一下config.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module.exports = {
lang: 'zh-CN',
title: '批哩FUN',
description: '批哩FUN',
head: [['link', { rel: 'icon', href: 'logo.jpg' }]],

themeConfig: {
logo: 'logo.jpg',

//顶部导航栏
navbar: [
{text:'我的博客', link: 'https://misakatang.cn'},
{text:'TTRSS', link: 'https://www.bilibifun.cn/ttrss'},
{text:'Portainer', link: 'https://www.bilibifun.cn/portainer'},
{text:'青龙面板', link: 'http://110.40.154.33:9006'},
{text:'NPS', link: 'https://www.bilibifun.cn/nps'},
{text:'Bitwarden', link: 'https://www.bilibifun.cn/bitwarden'},
{text:'RSS Hub', link: 'https://www.bilibifun.cn/rsshub'},
{text:'V2rayA', link: 'https://www.bilibifun.cn/v2raya'},
{text:'WEBDAV', link: 'https://www.bilibifun.cn/webdav'},
],
},
}

效果:批哩FUN

部署

因为暂时没有什么功能,而且Github Action操作服务器还没研究过,暂时就先把项目clone到服务器上然后写个定时任务每天跑一次构建到docker就行了

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FROM node:17-alpine as builder

COPY . /workdir
WORKDIR /workdir
RUN ls
RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
RUN cnpm -v
RUN cnpm i yarn tyarn -g
RUN tyarn -v
RUN tyarn
RUN tyarn docs:build

# 选择更小体积的基础镜像
FROM nginx:alpine
COPY --from=builder /workdir/docs/.vuepress/dist /usr/share/nginx/html

build.sh

1
2
3
4
5
6
7
8
9
git pull

docker build -t bilibifun-home .

(docker stop bilibifun-home && docker rm bilibifun-home) || true

docker run -p 9013:80 --name bilibifun-home -d bilibifun-home

echo y | docker system prune

home.conf

1
2
3
4
5
6
7
8
location / {
proxy_pass http://172.17.0.1:9013/;
proxy_set_header Host $host;
#proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

后续升级

  • 现在的server-conf还需要在服务器上通过shell来更改,如果有必要的话可以整一个运维工具或者装一个VSCode web版来进行在线的编辑
  • 官网首页的内容规划,如果有更多的内容的话就找一个更好的CI方式。
  • Jellyfin + Aria : 因为树梅派还跑着Aria下电影和番剧,可以考虑webdav之外的播放形式
  • 挂载阿里网盘为webdav用来存电影
  • 把aria穿透出来并且搞成配置式的url
0%