-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
170 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
created: 20240519054512803 | ||
creator: miRoox | ||
list: About 目录 | ||
modified: 20240519054516185 | ||
modifier: miRoox | ||
title: $:/StoryList | ||
type: text/vnd.tiddlywiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
created: 20240521040105748 | ||
creator: miRoox | ||
modified: 20240521040135572 | ||
modifier: miRoox | ||
tags: 软件 开源软件 网络代理 | ||
title: Clash | ||
tmap.id: 4f155d48-fa11-4d4e-8f27-ea8ab64d01f4 | ||
type: text/vnd.tiddlywiki | ||
|
||
Clash 代理软件是一种开源的网络代理工具 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
caption: 操作指南 | ||
created: 20240521051322594 | ||
creator: miRoox | ||
modified: 20240521051654156 | ||
modifier: miRoox | ||
tags: 分类 | ||
title: HowTos | ||
tmap.id: 67d0fda6-b3a8-43f7-929c-637f73408e66 | ||
type: text/vnd.tiddlywiki | ||
|
||
! HowTos | ||
|
||
<<list-links "[tag<currentTiddler>]">> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
created: 20240521035140500 | ||
creator: miRoox | ||
modified: 20240521035235756 | ||
modifier: miRoox | ||
tags: HowTos SAN存储 NVMe | ||
title: NVMe over TCP 搭建 | ||
tmap.id: 6313d27d-27d9-435c-a15a-2e13d3e40c64 | ||
type: text/vnd.tiddlywiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
created: 20240523110939972 | ||
creator: miRoox | ||
modified: 20240523112431426 | ||
modifier: miRoox | ||
tags: ZStack | ||
title: ZStack日志 | ||
tmap.id: 42f1cec9-033c-4cca-aa62-d3b689500c56 | ||
type: text/vnd.tiddlywiki | ||
|
||
相关日志记录地址: | ||
|
||
| ! 类型 | !日志路径 | !所在服务器 | | ||
| 管理节点日志 | `~zstack/apache-tomcat/logs/management-server.log` | 管理节点 | | ||
| 管理节点UI日志 | `~zstack/apache-tomcat/logs/zstack-ui.log` | 管理节点 | | ||
| 控制台代理日志 | `/var/log/zstack/zstack-console-proxy.log` | 管理节点 | | ||
| 管理节点部署日志 | `/var/log/zstack/deploy.log` | 管理节点 | | ||
| shell历史记录 | `/var/log/history.d/history` | 管理节点/计算节点 | | ||
| kvmagent日志 | `/var/log/zstack/zstack-kvmagent.log` | 计算节点 | | ||
| libvirt日志 | `/var/log/libvirt/libvirt.log` | 计算节点 | | ||
| vm qemu日志 | `/var/log/libvirt/qemu/${vm_uuid}.log` | 计算节点 | | ||
| 系统基本日志 | `/var/log/messages` | 所有 | | ||
| 镜像仓库日志 | `/var/log/zstack/zstack-store/zstore.log` | 镜像仓库 | | ||
| Ceph 主存储日志 | `/var/log/zstack/ceph-primarystorage.log` | Ceph 监控节点 | | ||
| Ceph 备份存储日志 | `/var/log/zstack/ceph-backupstorage.log` | Ceph 监控节点 | | ||
| VPC路由器的日志 | `/home/vyos/zvr/zvr.log` | VPC路由器 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
created: 20240521035545050 | ||
creator: miRoox | ||
modified: 20240521052355044 | ||
modifier: miRoox | ||
tags: Clash HowTos systemd | ||
title: 将Clash作为systemd服务 | ||
tmap.id: 6a5dfc00-eb0b-4a8a-8154-f107c7970424 | ||
type: text/vnd.tiddlywiki | ||
|
||
[[Clash]]执行程序放在`/usr/bin/clash` | ||
|
||
写一个转换日志给[[journald]]的[[Python]]程序: | ||
|
||
```py | ||
#!/bin/python3 | ||
|
||
import logging | ||
import re | ||
import shlex | ||
import sys | ||
import signal | ||
from subprocess import Popen, PIPE, STDOUT | ||
from systemd.journal import JournalHandler | ||
|
||
logger = logging.getLogger('clash') | ||
logger.propagate = False | ||
logger.addHandler(JournalHandler(SYSLOG_IDENTIFIER='clash')) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
LINE_PATTERN = re.compile(r'level=(\w+)\s+msg="(.+)"') | ||
|
||
def process_line(line: str): | ||
m = re.search(LINE_PATTERN, str(line)) | ||
if m: | ||
level = m.group(1) | ||
msg = m.group(2) | ||
match level: | ||
case 'debug': | ||
level = logging.DEBUG | ||
case 'info': | ||
level = logging.INFO | ||
case 'warning'|'warn': | ||
level = logging.WARNING | ||
case 'error'|'err': | ||
level = logging.ERROR | ||
case 'fatal'|'critical': | ||
level = logging.CRITICAL | ||
case _: | ||
level = logging.NOTSET | ||
logger.log(level, msg) | ||
else: | ||
logger.debug(line) | ||
|
||
def main(): | ||
cmd = ['/usr/bin/clash'] | ||
cmd.extend(sys.argv[1:]) | ||
logger.debug(' '.join(map(shlex.quote, cmd))) | ||
ps = Popen(cmd, stdout=PIPE, stderr=STDOUT) | ||
try: | ||
def forward_signal(signum, frame): | ||
ps.send_signal(signum) | ||
for s in [signal.SIGTERM, signal.SIGINT, signal.SIGABRT]: | ||
signal.signal(s, forward_signal) | ||
while ps.poll() is None: | ||
line = ps.stdout.readline().decode('utf-8').strip() | ||
if line: | ||
process_line(line) | ||
return ps.returncode | ||
finally: | ||
for s in [signal.SIGTERM, signal.SIGINT, signal.SIGABRT]: | ||
signal.signal(s, signal.Handlers.SIG_DFL) | ||
if ps.stdout: | ||
ps.stdout.close() | ||
if ps.stderr: | ||
ps.stderr.close() | ||
|
||
if __name__ == '__main__': | ||
exit(main()) | ||
``` | ||
|
||
同样放到`/usr/bin/clash.py` | ||
|
||
clash配置可能经常要改,出于方便,放在`/root/clash`下 | ||
|
||
`/etc/systemd/system/clash.service`: | ||
|
||
```ini | ||
[Unit] | ||
Description=Clash | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/python3 /usr/bin/clash.py -d /root/clash/ | ||
ExecStop=/bin/kill -- $MAINPID | ||
TimeoutStopSec=5 | ||
KillMode=process | ||
Restart=on-failure | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
注:目录根据自己的实际情况改一下 | ||
|
||
service文件放到`/etc/systemd/system/clash.service`,然后更新,启用启动服务 | ||
|
||
```sh | ||
sudo systemctl daemon-reload | ||
sudo systemctl enable clash.service | ||
sudo systemctl start clash.service | ||
``` |