现在我的第一个 ruby​​ 应用程序已经完成,如何在我的服务器上运行它?

发布于 2024-12-23 15:26:52 字数 563 浏览 2 评论 0原文

所以我已经成功完成了我的第一个 ruby​​ 应用程序:)

当我在本地对其进行编程时,我必须在终端中单独使用以下所有命令才能启动并运行它。问题是,当我关闭终端时,它们都会停止,所以即使我在服务器上注销 ssh,我也不知道如何保持它们打开。

首先,我让应用程序通过端口 9292 上的机架(sinatra 框架)运行,然后启动 redis,然后为 2 个 Resque 作业队列创建一个工作线程

rackup config.ru
redis-server
rake workers:start

我没有使用“生产/开发”结构,只是因为我还没有真正使用过还了解到这一点。我只是想简单地设置一下,然后我就可以回去了解这一切是如何工作的。所以我知道这不是专业应用程序的最佳方法,但现在我正在寻找最简单的方法(但仍然没有走捷径)。

我还相信我将使用乘客来让它正式运行。我不确定接下来的步骤是什么来启动和运行它,以便我可以注销并且它保持活动和工作状态。我也不知道是否必须单独运行这些命令,或者是否可以将它们全部放在一个文件中,所以我只需运行 passenger start 就结束了。

So I've successfully finished my first ruby app :)

When i programmed it locally, i have to use all the following commands below separately in terminal to get it up and running. The problem is when I close terminal they all stop, so I don't know how to keep them open even when i log out of ssh on my server.

First I get the app running via rack (sinatra framework) on port 9292, then start redis, and then create a single worker for 2 Resque job queues

rackup config.ru
redis-server
rake workers:start

I haven't been using "production/development" structures simply because I haven't really learned about that yet. I'm just trying to get it set up simply, then I can go back and learn how all that works. So i understand this isnt the best method for a professional app, but right now I'm looking for the easiest (but still without taking shortcuts).

I also believe I'm going to be using passenger to get it officially running. I'm not sure what the next steps are to get it up and running so i can log out and it just stays active and working. I also dont know if i have to run the commands separately or if I can put them all in one file somewhere so i just run passenger start and thats the end of it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三寸金莲 2024-12-30 15:26:52

如果您要使用 Passenger 托管您的应用程序,那么您将不会运行命令来启动服务器;相反,应用程序将仅作为 nginxhttpd,它将通过系统的 init(8) 工具。

init(8) 的配置方式因系统而异,但 SysV 风格的 init 通常会在 /etc/rc*.d/* 目录中包含脚本来控制启动,基于 Upstart 的系统 将在 /etc/init/ 中拥有配置文件,依此类推。此时,您不再需要寻找运行 passenger 应用程序的方法,而是寻找启动 Apache httpdnginx 的方法,这就是一个已经很好解决的问题。

If you're going to use Passenger to host your application then you won't be running commands to start the server; instead, the application will simply run as part of nginx or httpd, which will be started via the system's init(8) tool.

How init(8) is configured varies considerably from system to system, but SysV-style init will typically have scripts in /etc/rc*.d/* directories to control startup, Upstart-based systems will have config files in /etc/init/, and so on. At that point, you're not looking for ways to run passenger applications so much as a way to start Apache httpd or nginx, and that's an already well-solved problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文