1. Tududi项目概述
Tududi是一款轻量级的个人任务与项目管理工具,专为独立开发者、自由职业者和小型团队设计。我在过去三年中尝试过各类任务管理工具,最终选择自建Tududi系统,主要是因为它完美平衡了简洁性和功能性。与那些臃肿的企业级解决方案不同,Tududi的核心优势在于其模块化设计和极低的学习曲线。
这个工具最初是德国开发者Martin在2019年作为开源项目发布的,经过社区贡献现已支持多平台运行。我选择它的另一个重要原因是其数据完全本地存储的特性,这对注重隐私的用户来说是个福音。通过本教程,你将能在20分钟内完成从环境准备到基础配置的全流程。
2. 环境准备与安装
2.1 系统要求检查
Tududi对硬件要求极低,但需要确保:
- 操作系统:Linux/Windows/macOS(推荐Linux服务器)
- 内存:至少512MB空闲内存
- 存储:200MB可用空间
- 运行时环境:Node.js 14+ 和 Python 3.6+
在Ubuntu上验证环境的命令:
bash复制node -v # 检查Node.js版本
python3 --version # 检查Python版本
free -m # 查看内存情况
注意:如果使用Windows系统,建议通过WSL2运行以获得最佳性能
2.2 依赖安装步骤
对于Debian系Linux用户,按顺序执行:
bash复制# 更新软件源
sudo apt update && sudo apt upgrade -y
# 安装基础依赖
sudo apt install -y git curl python3-pip
# 安装Node.js(通过官方源)
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs
# 验证安装
npm --version
pip3 --version
遇到网络问题时,可以尝试更换npm源:
bash复制npm config set registry https://registry.npmmirror.com
3. Tududi核心部署流程
3.1 源码获取与初始化
推荐从官方Git仓库克隆最新稳定版:
bash复制git clone -b stable https://github.com/tududi/tududi-core.git
cd tududi-core
# 安装前端依赖
npm install --legacy-peer-deps
# 安装后端依赖
pip3 install -r requirements.txt
如果下载速度慢,可以使用国内镜像源:
bash复制git clone -b stable https://gitee.com/tududi-mirror/tududi-core.git
3.2 数据库配置
Tududi默认使用SQLite,也支持MySQL/PostgreSQL。以下是MySQL配置示例:
- 修改config/database.ini:
ini复制[default]
driver = mysql
host = 127.0.0.1
port = 3306
database = tududi_db
username = tududi_user
password = your_strong_password
- 初始化数据库:
bash复制python3 manage.py db init
python3 manage.py db migrate
python3 manage.py db upgrade
3.3 服务启动与验证
启动后端API服务:
bash复制python3 run.py --port 5000 --debug
另开终端启动前端:
bash复制npm run dev
访问测试:
bash复制curl http://localhost:5000/api/status
应返回{"status":"ok","version":"1.2.3"}
4. 系统配置与优化
4.1 基础参数调优
修改config/app.ini提升性能:
ini复制[performance]
worker_threads = 4 # CPU核心数×2
task_queue_size = 100
cache_size = 256 # MB
[security]
enable_https = true
csrf_protection = true
4.2 反向代理配置(Nginx示例)
创建/etc/nginx/sites-available/tududi.conf:
nginx复制server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
}
location /api {
proxy_pass http://127.0.0.1:5000;
proxy_set_header X-Real-IP $remote_addr;
}
}
启用配置:
bash复制sudo ln -s /etc/nginx/sites-available/tududi.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
5. 日常维护与问题排查
5.1 自动化管理脚本
创建维护脚本/usr/local/bin/tududi-manage:
bash复制#!/bin/bash
case $1 in
start)
cd /opt/tududi-core
nohup python3 run.py > api.log 2>&1 &
nohup npm run start > ui.log 2>&1 &
;;
stop)
pkill -f "python3 run.py"
pkill -f "npm run start"
;;
backup)
sqlite3 /opt/tududi-core/data.db ".backup /backups/tududi-$(date +%F).db"
;;
esac
5.2 常见错误解决方案
- 端口冲突问题:
bash复制ss -tulnp | grep ':5000\|:3000' # 查看端口占用
kill -9 <PID> # 终止冲突进程
- 数据库连接失败:
bash复制mysql -u tududi_user -p
> GRANT ALL PRIVILEGES ON tududi_db.* TO 'tududi_user'@'localhost';
> FLUSH PRIVILEGES;
- 前端编译错误:
bash复制rm -rf node_modules package-lock.json
npm cache clean --force
npm install
6. 进阶使用技巧
6.1 数据迁移方案
从其他工具导入任务:
python复制# 示例:从CSV导入
import pandas as pd
from tududi.models import Task
df = pd.read_csv('old_tasks.csv')
for _, row in df.iterrows():
Task.create(
title=row['title'],
description=row['desc'],
due_date=row['due']
)
6.2 移动端适配技巧
通过PWA实现移动访问:
- 修改public/manifest.json
- 注册Service Worker:
javascript复制// src/sw.js
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((response) => response || fetch(event.request))
);
});
6.3 插件开发基础
创建自定义插件模板:
python复制# plugins/my_plugin/__init__.py
from tududi.plugins import BasePlugin
class MyPlugin(BasePlugin):
def register(self):
self.app.add_api_route('/my-plugin', self.handler)
async def handler(self):
return {"message": "Hello from MyPlugin!"}
在config/plugins.ini中启用:
ini复制[plugins]
active = my_plugin, calendar, reports
7. 安全加固措施
7.1 基础安全配置
- 修改默认JWT密钥:
bash复制python3 -c "import secrets; print(secrets.token_urlsafe(32))"
将输出填入config/security.ini的jwt_secret_key
- 启用登录验证:
ini复制[auth]
enable_login = true
min_password_length = 12
max_attempts = 5
7.2 定期维护任务
设置cron作业:
bash复制# 每天3AM备份
0 3 * * * /usr/local/bin/tududi-manage backup
# 每周清理日志
0 4 * * 0 find /var/log/tududi/ -type f -mtime +30 -delete
8. 性能监控方案
8.1 基础监控配置
安装Prometheus exporter:
bash复制pip install prometheus-client
创建metrics.py:
python复制from prometheus_client import start_http_server, Gauge
tasks_count = Gauge('tududi_tasks_total', 'Total tasks in system')
def update_metrics():
tasks_count.set(Task.query.count())
8.2 日志分析技巧
使用GoAccess分析访问日志:
bash复制goaccess /var/log/nginx/tududi.access.log \
--log-format=COMBINED \
--output=/var/www/html/report.html
关键指标监控命令:
bash复制# 内存使用
watch -n 5 "free -m | grep 'Mem:'"
# API响应时间
tail -f api.log | awk '/API call/{print $NF}'
9. 备份与恢复策略
9.1 完整备份流程
- 创建备份脚本
/backups/tududi-backup.sh:
bash复制#!/bin/bash
BACKUP_DIR="/backups/$(date +%F)"
mkdir -p $BACKUP_DIR
# 数据库备份
sqlite3 /opt/tududi-core/data.db ".backup $BACKUP_DIR/data.db"
# 配置文件备份
cp -r /opt/tududi-core/config $BACKUP_DIR/
# 打包压缩
tar -czf /backups/tududi-$(date +%F).tgz $BACKUP_DIR
- 设置可执行权限:
bash复制chmod +x /backups/tududi-backup.sh
9.2 灾难恢复步骤
从备份恢复的完整流程:
bash复制# 解压备份
tar -xzf tududi-2023-01-01.tgz -C /tmp/restore
# 恢复数据库
mv /tmp/restore/data.db /opt/tududi-core/
# 恢复配置
cp -r /tmp/restore/config /opt/tududi-core/
# 重启服务
/usr/local/bin/tududi-manage stop
/usr/local/bin/tududi-manage start
10. 扩展与集成方案
10.1 邮件通知集成
配置SMTP设置:
ini复制[notifications]
enable_email = true
smtp_server = smtp.example.com
smtp_port = 587
smtp_user = your@email.com
smtp_pass = your_password
from_address = noreply@yourdomain.com
测试邮件发送:
bash复制python3 -c "
from tududi.notifications import send_test_email;
send_test_email('test@example.com')
"
10.2 第三方API对接
示例:集成GitHub Issues:
python复制import requests
def sync_with_github():
issues = requests.get(
'https://api.github.com/repos/owner/repo/issues',
headers={'Authorization': 'token YOUR_GITHUB_TOKEN'}
).json()
for issue in issues:
if not Task.query.filter_by(external_id=f'gh:{issue["id"]}').first():
Task.create(
title=f'GitHub: {issue["title"]}',
description=issue['body'],
external_id=f'gh:{issue["id"]}'
)
设置定时同步:
bash复制# 每小时同步一次
0 * * * * /opt/tududi-core/scripts/sync_github.py