我目前正在开发一个聊天程序,其中服务器为 Ubuntu + Swift,客户端为 JavaScript + WebSocket。最终我达到了 0.1 版本,我需要将其部署以供公众使用。
我正在租用 Ubuntu 16.04 LST 的虚拟云服务器,我安装了 Swift 3 和我开发的聊天服务器作为 .swift
文件的集合。我可以使用 swift 命令编译和运行我的聊天服务器。但是一旦我关闭 SSH 连接,服务器就会停止。是的,我能理解为什么。
- 如何在我的虚拟云服务器上永久启动我的聊天服务器?
- 我真的需要将其作为一项服务吗?
service squid start
然后怎么办?
从哪里开始?我在互联网上搜索了很多但找不到任何示例或建议。有什么帮助吗?提前谢谢你。
最佳答案
https://wiki.ubuntu.com/SystemdForUpstartUsers Systemd 服务示例
/lib/systemd/system/foo.service:
[Unit]
Description=Job that runs the foo daemon
Documentation=man:foo(1)
[Service]
Type=forking
Environment=statedir=/path/to/swift/usr/lib
ExecStart=/path/to/swiftBinary
[Install]
WantedBy=multi-user.target
关于linux - 如何在 Ubuntu linux 上启动和停止 Apple 基于 Swift 的生产服务器(我编写的程序)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41570829/