现在我的第一个 ruby 应用程序已经完成,如何在我的服务器上运行它?
所以我已经成功完成了我的第一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您要使用 Passenger 托管您的应用程序,那么您将不会运行命令来启动服务器;相反,应用程序将仅作为
nginx
或httpd
,它将通过系统的init(8)
工具。init(8)
的配置方式因系统而异,但 SysV 风格的init
通常会在/etc/rc*.d/*
目录中包含脚本来控制启动,基于 Upstart 的系统 将在/etc/init/
中拥有配置文件,依此类推。此时,您不再需要寻找运行passenger
应用程序的方法,而是寻找启动 Apachehttpd
或nginx
的方法,这就是一个已经很好解决的问题。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
orhttpd
, which will be started via the system'sinit(8)
tool.How
init(8)
is configured varies considerably from system to system, but SysV-styleinit
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 runpassenger
applications so much as a way to start Apachehttpd
ornginx
, and that's an already well-solved problem.