- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为我的应用创建一个 vapor API。在我的本地计算机 (Mac OS) 上,我所有的代码和 API 都运行良好,但是当我将它上传到我的 ubuntu 服务器时,它崩溃了...
我已经做了以下代码:
Steam 清洁
Steam 更新
Vapor 构建
这些命令都不会返回任何类型的错误,但是当我运行 vapor 时会发生以下情况:
root@rt-server:/usr/local/uprising/server# vapor run
运行服务器...
root@rt-server:/usr/local/uprising/server#
稍微搜索并尝试解决我的问题,我发现如果我注释以下代码 (configure.swift),我可以运行 vapor:
// Register Mongo Client
let client = try! MongoClient()
let db = client.db("myDB")
let collection:MongoCollection<Document>
do {
collection = try db.createCollection("myCollection")
} catch {
collection = db.collection("myCollection")
}
// Create an unique index on timestamp
// because I expect only one daily
let indexOptions = IndexOptions(name: "timestamp", unique: true)
let model = IndexModel(keys: [ "timestamp": 1] , options: indexOptions)
do {
try collection.createIndex(model)
} catch {
print("Index already exist!")
}
services.register(client)
我有一些问题可能会帮助我弄清楚如何解决我的问题:
如何在 ubuntu 上使用命令行调试 vapor?在我的 Mac 中,当我使用 xcode 时很容易...
我可以测试我的 MongoDB C 驱动程序是否正确安装了吗?
有谁知道我做错了什么?它在我的 Mac 上完美运行...
抱歉我的英语不好...如果有人知道如何帮助我,我将不胜感激!
最佳答案
swift MacOS 运行环境 != swift Linux 运行环境。这意味着,在 MacOS 中构建并完美运行的代码通常不会在 Linux 中编译。我实现了几个Linux swift项目,我的建议是:从项目开始就在Linux中开发Linux swift项目!对于您的情况:
1) 在大多数情况下,Linux swift 项目使用 docker 在生产环境中运行。
2) 获取与docker容器中相同环境的Linux主机
3) 将你的项目迁移到 Linux 主机上
4) 在 Linux 主机中,您可以构建、执行和调试它。
此外,对于我的一个 Linux Swift 项目,当我需要访问 MongoDB 时,我测试了几个框架和 MongoKitten对我来说是最好的。
关于swift - 在 ubuntu 上使用 MongoSwift 时 Vapor 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56116895/
我有一个 iOS 应用程序,计划与 MongoDB 集成。安装 pod 文件后,在构建时我收到大约 100 个错误,但我不太确定是什么原因导致的或如何修复它们。 添加了一些错误的屏幕截图。它们几乎完全
我正在尝试为我的应用创建一个 vapor API。在我的本地计算机 (Mac OS) 上,我所有的代码和 API 都运行良好,但是当我将它上传到我的 ubuntu 服务器时,它崩溃了... 我已经做了
当我运行我的项目时,我将 swift 包依赖项 mongoSwift 驱动程序添加到我的 Xcode 项目中,错误显示为: Library not loaded: /usr/local/opt/mon
我是一名优秀的程序员,十分优秀!