英文:
Keep Go script running on Linux server after ssh connection is closed
问题
我有一个Go脚本,它创建一个HTTP请求并响应任何传入的请求。我希望这个脚本在Linux服务器上运行。然而,我不能永远保持ssh连接处于活动状态,当连接断开时,脚本也会停止,这是预期的。我知道NodeJS有一个名为"forever"的工具可以解决这个问题。我想知道是否有类似的工具适用于Golang,因为我找不到相关信息。对于如何解决这个问题的其他建议也非常欢迎。
英文:
I have a Go script that creates an HTTP request and responds to any incoming requests. I want this script to run on a Linux server. However, I can't keep the ssh connection active forever, and when it disconnects the script also stops, as expected. I know that you have 'forever' for NodeJS that fixes this issue. I was wondering if something similar also exists for Golang, as I was not able to find anything. Any other tips on how to fix this are also very welcome.
答案1
得分: 1
这里主要有三个选项,一个是使用nohup命令,另一个是使用screen命令,最后一个是screen的升级版本byobu。在阅读了这三个命令之后,我实际上更喜欢使用byobu命令,因为byobu命令更强大,是screen的升级版本,并且界面更友好。
英文:
There are mainly three options here, one is to use the nohup command, the other is to use the screen command, and the last is the upgraded version of byobu of screen. After reading these three commands, I actually prefer to use the byobu command, because the byobu command is more powerful, an upgraded version of screen, and the interface is more friendly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论