linux - 如何在 Ubuntu linux 上启动和停止 Apple 基于 Swift 的生产服务器(我编写的程序)?

标签 linux swift ubuntu service

我目前正在开发一个聊天程序,其中服务器为 Ubuntu + Swift,客户端为 JavaScript + WebSocket。最终我达到了 0.1 版本,我需要将其部署以供公众使用。

我正在租用 Ubuntu 16.04 LST 的虚拟云服务器,我安装了 Swift 3 和我开发的聊天服务器作为 .swift 文件的集合。我可以使用 swift 命令编译和运行我的聊天服务器。但是一旦我关闭 SSH 连接,服务器就会停止。是的,我能理解为什么。

  1. 如何在我的虚拟云服务器上永久启动我的聊天服务器?
  2. 我真的需要将其作为一项服务吗? 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/

相关文章:

ios - 当 Objective-C 作为桥梁时,快速在索引 0 处发出检查计数

python - 如何一键运行Python脚本?

apache - at 命令在 ubuntu apache 错误 'You do not have permission to use at'

regex - 使用脚本提取 Ubuntu 传感器命令

php - 权限 - PHP 和 FTP

Linux 终端要检查的两个条件

c - C如何区分一个字节长的字符和一个2字节长的字符?

swift - SpriteKit swift : How to make a sprite jump in place when tapped?

linux -/var/spool/mail 和/var/mail/root 相同的 inode 但只有一个链接数

ios - 阴影图像在第一个 viewWillAppear 上不起作用