Mastodon
  • 什么是 Mastodon?
  • 使用 Mastodon
    • 注册帐户
    • 设置你的个人资料
    • 在你的账户发布内容
    • 使用网络功能
    • 处理不想看到的内容
    • 推广你和他人
    • 进行偏好设置
    • 更多设置
    • 在站点外使用 Mastodon
    • 迁移或离开账户
    • 运行你自己的站点
  • 运营 Mastodon
    • 准备你的服务器
    • 从源代码安装
    • 配置你的环境
    • 安装可选功能
      • 对象存储
      • 洋葱服务
      • 验证码
      • 单点登录
    • 配置全文搜索
    • 设置你的新实例
    • 使用管理 CLI
    • 升级到新版本
    • 备份你的服务器
    • 迁移到新机器
    • 扩大你的站点规模
    • 审核操作
    • 故障排除
      • 数据库索引损坏
    • 用户组
  • 开发 Mastodon 应用
    • API 入门指南
    • 使用公开数据
    • 获取客户端应用访问权限
    • 使用帐户登录
    • 库与实现
  • 向 Mastodon 项目做贡献
    • 技术概览
    • 设置开发环境
    • 代码结构
    • 路由
    • 漏洞赏金与责任披露
  • 遵循的标准
    • ActivityPub
    • WebFinger
    • 安全性
    • Microformats
    • OAuth
    • Bearcaps
  • REST API
    • Datetime 格式
    • 指南与最佳实践
    • OAuth 令牌
    • OAuth 作用域
    • 速率限制
  • API 方法
    • apps
      • oauth
      • emails
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • followed_tags
      • suggestions
      • tags
    • profile
    • statuses
      • media
      • polls
      • scheduled_statuses
    • timelines
      • conversations
      • lists
      • markers
      • streaming
    • grouped notifications
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
      • announcements
    • admin
      • accounts
      • canonical_email_blocks
      • dimensions
      • domain_allows
      • domain_blocks
      • email_domain_blocks
      • ip_blocks
      • measures
      • reports
      • retention
      • trends
    • proofs
    • oembed
  • API 实体
    • Account
    • AccountWarning
    • Admin::Account
    • Admin::CanonicalEmailBlock
    • Admin::Cohort
    • Admin::Dimension
    • Admin::DomainAllow
    • Admin::DomainBlock
    • Admin::EmailDomainBlock
    • Admin::Ip
    • Admin::IpBlock
    • Admin::Measure
    • Admin::Report
    • Announcement
    • Appeal
    • Application
    • Context
    • Conversation
    • CustomEmoji
    • DomainBlock
    • Error
    • ExtendedDescription
    • FamiliarFollowers
    • FeaturedTag
    • Filter
    • FilterKeyword
    • FilterResult
    • FilterStatus
    • IdentityProof
    • Instance
    • List
    • Marker
    • MediaAttachment
    • Notification
    • NotificationPolicy
    • NotificationRequest
    • Poll
    • Preferences
    • PreviewCard
    • PreviewCardAuthor
    • PrivacyPolicy
    • Reaction
    • Relationship
    • RelationshipSeveranceEvent
    • Report
    • Role
    • Rule
    • ScheduledStatus
    • Search
    • Status
    • StatusEdit
    • StatusSource
    • Suggestion
    • Tag
    • TermsOfService
    • Token
    • Translation
    • V1::Filter
    • V1::Instance
    • V1::NotificationPolicy
    • WebPushSubscription

技术概览

关于 Mastodon 架构的描述。

      • 环境

Mastodon 是一个使用 React.js 前端的 Ruby on Rails 应用程序。 它遵循这些框架的标准实践,因此如果你已经熟悉 Rails 或 React.js,在这里你不会发现任何意外。

在开发环境中,使用 Mastodon 的最佳方式是在你的系统上安装所有依赖项,而不是使用 Docker 或 Vagrant。 你需要 Ruby、Node.js、PostgreSQL 和 Redis,这是 Rails 应用程序的一组相当标准的依赖项。

有关安装这些依赖项的教程可以在文档的“运行 Mastodon”部分中的“从源代码安装”页面上找到。 按照“运行 Mastodon”部分中的安装指南操作后,请查看“设置开发环境”页面,以获取有关如何配置开发环境的更多说明。

环境

“环境”是一组用于特定用例的配置值。 环境可能是:开发(development),你通常打算在其中更改代码;测试(test),你通常打算在其中运行自动化测试套件;暂存(staging),旨在向最终用户预览代码;以及生产,旨在面向最终用户。 Mastodon 带有开发、测试和生产的配置。

RAILS_ENV 的默认值为 development,因此你无需设置任何额外的东西即可在开发模式下运行 Mastodon。 事实上,Mastodon 的所有配置都具有适用于开发环境的正确默认值,因此除非你需要自定义某些内容,否则你不需要 .env 文件。 以下是开发环境和生产环境之间的一些不同行为:

  • 当你更改 Ruby 代码时,代码会自动重载,这意味着你无需重新启动 Rails 服务端进程即可查看更改
  • 你遇到的所有错误的堆栈跟踪都会在浏览器中显示,而不是隐藏在通用错误页面之后
  • Webpack 会持续运行,并在你更改任何前端文件时重新编译 JS 和 CSS 资源,并且页面会自动重新加载
  • 默认禁用缓存
  • 在 db:seed 期间会自动创建一个电子邮件为 admin@localhost:3000 且密码为 mastodonadmin 的管理员帐户

应该注意的是,与 Mastodon 一起分发的 Docker 配置针对生产环境进行了优化,因此极其不适合开发。 另一方面,Vagrant 配置专门用于开发环境,而不是生产用途。

翻译状态: 本文是英文页面 Technical overview 的翻译,最后翻译时间:2025-04-21,点击这里可以查看翻译后页面的改动。

最后更新于 April 21, 2025 · 改进此页面
也可在此找到: English

赞助商

Dotcom-Monitor LoadView Stephen Tures Swayable SponsorMotion

加入Mastodon · 博客 ·

查看源代码 · CC BY-SA 4.0 · 版权信息