Files
k3s/006-其他/code-server.md
2026-02-05 00:11:05 +08:00

40 lines
6.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
我已经准备好了服务文件。现在请执行以下命令来完成设置:
# 1. 将服务文件复制到系统目录(需要输入密码)
sudo cp /tmp/code-server.service /etc/systemd/system/
# 2. 重载 systemd 配置
sudo systemctl daemon-reload
# 3. 启用开机自启动
sudo systemctl enable code-server
# 4. 立即启动服务
sudo systemctl start code-server
# 5. 查看服务状态
sudo systemctl status code-server
或者你可以一次性执行:
sudo cp /tmp/code-server.service /etc/systemd/system/ && \
sudo systemctl daemon-reload && \
sudo systemctl enable --now code-server && \
sudo systemctl status code-server
服务配置说明:
- 监听地址0.0.0.0:8080所有网络接口
- 工作目录:/home/fei
- 运行用户fei
- 自动重启:服务崩溃后 10 秒自动重启
常用管理命令:
- 查看状态sudo systemctl status code-server
- 停止服务sudo systemctl stop code-server
- 重启服务sudo systemctl restart code-server
- 查看日志sudo journalctl -u code-server -f
- 禁用开机启动sudo systemctl disable code-server
如果你需要修改配置(如端口号或其他参数),可以编辑 /etc/systemd/system/code-server.service 文件,然后执行 sudo systemctl daemon-reload 和 sudo systemctl restart code-server