1774597379

This commit is contained in:
Docker7530
2026-03-27 15:43:03 +08:00
parent ab0cbad418
commit e4a339bd77
43 changed files with 2973 additions and 179 deletions
+40
View File
@@ -0,0 +1,40 @@
# 常用 Screen 命令大全
## 创建会话(最常用)
- `screen -U -S vllm_server` → 新建并命名
- `screen -U -dmS vllm_server`**新建后立即分离**(最推荐!直接后台启动)
- `screen -U -dmS vllm_server "python -m vllm serve …"` → 新建 + 直接执行命令(一键启动服务)
## 管理会话
- `screen -U -ls``screen -U -list` → 列出所有会话(你现在用的)
- `screen -U -r` → 进入最后一个会话
- `screen -U -r vllm_server` → 按名字进入(推荐,比数字更稳)
- `screen -U -r 89505` → 只输入数字也可以(简写)
- `screen -U -S vllm_server -X quit` → 杀死指定会话(你现在用的)
- `screen -wipe` → 清理已死亡的会话记录(偶尔用)
# 在 screen 里面的快捷键(记住这几个就够用 90%)
| 快捷键 | 功能 |
|--------|------|
| `Ctrl-a ?` | 显示帮助(所有快捷键列表) |
| `Ctrl-a c` | 新建一个窗口(像 tab |
| `Ctrl-a n` / `Ctrl-a p` | 切换到下一个/上一个窗口 |
| `Ctrl-a 0~9` | 直接跳到第几个窗口 |
| `Ctrl-a d` | 分离(退出) |
| `Ctrl-a k` | 杀死当前窗口(确认 y |
| `Ctrl-a A` | 重命名当前窗口(好认) |
| `Ctrl-a "` | 显示窗口列表,选择切换 |
# 高级实用技巧
- 滚动屏幕:`Ctrl-a [` → 进入复制模式,用上下键翻历史,按 `Esc` 退出
- 发送命令给后台会话:`screen -S vllm_server -X stuff "echo hello\n"`
- 自动启动 vLLM(推荐写进脚本):
```bash
screen -U -dmS vllm_server
screen -S vllm_server -X stuff "python -m vllm serve --model /root/autodl-tmp/DeepSeek-R1-1.5B --port 8000\n"
```
+3
View File
@@ -0,0 +1,3 @@
```
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') %}{%- for message in messages %}{%- if message['role'] == 'system' %}{% set ns.system_prompt = message['content'] %}{%- endif %}{%- endfor %}{{bos_token}}{{ns.system_prompt}}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<User>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is none %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls']%}{%- if not ns.is_first %}{{'<Assistant><tool▁calls▁begin><tool▁call▁begin>' + tool['type'] + '<tool▁sep>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<tool▁call▁end>'}}{%- set ns.is_first = true -%}{%- else %}{{'\\n' + '<tool▁call▁begin>' + tool['type'] + '<tool▁sep>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<tool▁call▁end>'}}{{'<tool▁calls▁end><end▁of▁sentence>'}}{%- endif %}{%- endfor %}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is not none %}{%- if ns.is_tool %}{{'<tool▁outputs▁end>' + message['content'] + '<end▁of▁sentence>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = message['content'].replace('</think>', '').split('<think>')[-1] %}{% endif %}{{'<Assistant>' + content + '<end▁of▁sentence>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<tool▁outputs▁begin><tool▁output▁begin>' + message['content'] + '<tool▁output▁end>'}}{%- set ns.is_output_first = false %}{%- else %}{{'\\n<tool▁output▁begin>' + message['content'] + '<tool▁output▁end>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<tool▁outputs▁end>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<Assistant>'}}{% endif %}
```
+53
View File
@@ -0,0 +1,53 @@
`x-csrf-token` 是 Spring Security CSRF 防护机制 的一部分,用于防止跨站请求伪造(CSRF)攻击。
后端接口需要通过请求头接收前端携带的 CSRF token,以验证请求的合法性。
其中 IBSCsrfTokenRepository 管理 CSRF token,是一个 `UUID.randomUUID().toString()` 随机字符串
登录成功后,SecurityConfig.writeLoginSuccessResult()SecurityConfig.java:482)会将 token 存入 sessionrequest.getSession().setAttribute(IBSCsrfTokenRepository.class.getName() + ".CSRF_TOKEN", token)
同时通过 /admin/getCurrentUser 接口返回给前端:userVO.setCsrfToken(csrfToken.getToken())
```
前端获取 Token
前端有两套机制,取决于环境:
生产环境(cdn-web 模板):页面通过 Thymeleaf 模板将 token 渲染到 HTML meta 标签中
<meta name="_csrf" th:content="${_csrf.token}">
<meta name="_csrf_header" th:content="${_csrf.headerName}">
前端通过 getCsrfHeaderFromMeta() 读取这两个 meta 标签,动态设置请求头。
非生产环境(IBS-web):通过调用 /admin/getCurrentUser 接口获取 token 并缓存在 window.XTOKEN 中。
```
后端 Filter 链验证 Token
RequestReplaceFilter
```
response.setHeader("Access-Control-Allow-Headers",
"content-type,x-requested-with,Authorization, x-request-with,x-ui-request,lang,x-csrf-token,csrf-token");
```
```
在 SecurityConfig.csrf() 配置中(SecurityConfig.java:211-218),以下路径不进行 CSRF 校验:
// CSRF
String[] ignorePathes = {"/v1/**", "/v2/**", "/v1.0/**", "/analyzer/**", "/puppet/**", "/api/**",
"/sso/**", "/ssoapi/**", "/dss/prohibit/**", "/dss/v1/log/subscribe/callback", "/portal/**",
"/param/config/**", "/bboss/**", "/sync/BBOSS/**", "/download/exportFile", "/action", "/actionpm",
"/action/cms", "/action/cdn/statistics", "/action/enterprise/domains","/action/enterprise/productId/domains",
"/action/js", "/content/delivery/**", "/information/**","/testAction","/api/v2/**",
"/home/page/help/Doc/**", "/home/page/security/**", "/query/cmcc/party/**", "/query/enterprise/domain/info", "/v2.0/log/template/**"};
http.csrf().ignoringAntMatchers(ignorePathes)
.csrfTokenRepository(new IBSCsrfTokenRepository(Arrays.asList(ignorePathes)));//不塞在cookie中
```
如果请求路径在 ignorePathes 列表中(如 /v1/**, /api/**, /action, /actionpm 等),loadToken 返回硬编码的 "1111111111",此时:
请求带 X-CSRF-TOKEN: 1111111111 → 可以通过
请求带 X-CSRF-TOKEN: 任意UUID → 失败
+139
View File
@@ -0,0 +1,139 @@
```
{
"model": "deepseek-chat",
"messages": [
{
"role": "user",
"content": "北京现在的天气怎么样?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取指定城市的天气信息",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "城市名称"
}
},
"required": [
"city"
]
}
}
}
],
"tool_choice": "auto"
}
{
"id": "06bcc2b7-602a-474b-bdd3-01cea249b121",
"object": "chat.completion",
"created": 1774519072,
"model": "deepseek-chat",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "我来帮您查询北京的天气情况。",
"tool_calls": [
{
"index": 0,
"id": "call_00_s4Qs5fJiG0yeRTpOgYxnxRyp",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"北京\"}"
}
}
]
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 309,
"completion_tokens": 51,
"total_tokens": 360,
"prompt_tokens_details": {
"cached_tokens": 0
},
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 309
},
"system_fingerprint": "fp_eaab8d114b_prod0820_fp8_kvcache_new_kvcache"
}
```
```
{
"model": "deepseek-chat",
"messages": [
{
"role": "user",
"content": "给我返回一个水果的信息,包含名称和颜色"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "fruit",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "水果名称"
},
"color": {
"type": "string",
"description": "水果颜色"
}
},
"required": [
"name",
"color"
]
}
}
}
}
```
```
{
"id": "chatcmpl-2b2225c5-02d0-4817-8039-329b3c790128",
"object": "chat.completion",
"created": 1774519551,
"model": "gpt-5.4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\"color\":\"红色\",\"name\":\"苹果\"}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 80,
"completion_tokens": 17,
"total_tokens": 97,
"prompt_tokens_details": {},
"completion_tokens_details": {
"reasoning_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}
```
+24
View File
@@ -0,0 +1,24 @@
```
http://dev.p.cdn.10086.cn:8080
/statistics/getHitRatio
?cpId=*
&product=*
&affectAreas=
&domainNames=
&provider=*
&startTime=2026-03-27%2010:25
&endTime=2026-03-27%2010:25
&productId=
&isps=
&granular=0
&_=1774580169469
```
com.cmcc.cdn.platform.selfservice.controller.StatisticsController#getHitRatio
给我梳理下这个接口的功能,输出一个 markdown 文档到项目的根目录。
主要是用到哪些参数,有哪些校验,有没有参数转换和默认值。掉了哪些三方接口,调了接口后做了哪些事情。尽量清晰。注意细节。