Windows 7 上 Rails 3.1 中本地使用的应用程序的最佳部署策略? [英] Best deployment strategy for local used application in Rails 3.1 on Windows 7?

查看:37
本文介绍了Windows 7 上 Rails 3.1 中本地使用的应用程序的最佳部署策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Rails 3.1 中开发 2 个应用程序(即将升级),并且注意到我当前的策略有其缺点.我目前正在做的是:

I am developing 2 applications in Rails 3.1 (will upgrade soon), and have noticed that my current strategy has its drawbacks. What I am doing currently is:

  • 直接在开发目录上工作,使用 Git 进行版本控制(这对我来说非常适合).
  • 我已经定义了这样的数据库(省略了不感兴趣的部分):

  • Work directly on the development directory, have there version control with Git (which works perfect for me).
  • I have defined the databases like (omitted not interesting parts):

development:
  database: db/dev.db
production:
  database: db/dev.db

  • 我有两个应用程序一直在生产模式下运行,其中端口定义为 3008 和 3009.

  • I have both applications running all the time in production mode, where the ports are defined as 3008 and 3009.

    我注意到以下事情不太好用.

    I have noticed that the following things don't work very well.

    • 当我更改 CSS 或 Javascript 文件时,我经常要清理(以及在开发后重建)资产.
    • 有时,开发服务器会从一台服务器获取文件(CSS 和 Javascript)并将其用于另一台服务器.我必须手动清理浏览器的缓存以避免这种情况.

    在我的计算机上本地并行开发和使用这两个应用程序的更好策略是什么?欢迎任何提示和提示.我应该为此使用部署工具 (Capistrano) 吗?我应该为鸿沟推出我自己的 Rake 任务吗?还是我错过了一些可以治愈伤口的魔法开关(听起来很可悲:-))?

    What would be a better strategy to develop and use the two applications in parallel locally on my computer? Any tips and hints are welcome. Should I use a deployment tool (Capistrano) for that? Shall I roll my own Rake task for the divide? Or do I miss some magic switch that will heal the wounds (sounds pathetic :-))?

    推荐答案

    最后是混合变化,所以我回答我自己的问题,希望其他人可以从中学到一些东西.最后,有 2 个主要决定(和一些次要决定):

    At the end, it is a mix of changes, so I answer my own questions and hope that others may learn something from it. At the end, there are 2 major decisions (and some minor ones):

    • 使用不同的代码库进行开发和生产,即使在同一台机器上.添加另一个(裸机)以同步两者.只从开发中推送,只从生产中拉取.
    • 始终为不同的应用程序使用不同的端口.制定一个方案,如:
      • appA:开发 ==> 4001,生产 ==> 3001
      • appB:开发 ==> 4002,生产 ==> 3002
      • ...

      这是我所做的更改.rails/root 是我的应用的根目录,整体目录结构如下:

      Here are the changes that I have done. rails/root is the root directory of my application, the overall directory structure is the following:

      rails/
        root/
        another/
        ...
        bare/
          root.git/
          another.git/
          ...
        production/
          root/
          another/
          ...
      

      • 从旧存储库创建 2 个新存储库,一个作为 存储库,另一个仅用于生产:

        • Create 2 new repositories from the old one, one as a bare repository, the other one for production only:

          1. mkdir rails/production
          2. mkdir rails/bare
          3. cd rails/bare
          4. git clone ../root --bare
          5. cd ../root
          6. git remote add bare ../bare/root
          7. cd rails/production
          8. git clone ../bare/root
          9. cd root
          10. git remote add bare ../../bare/root

        • 不要将一个(相同的)数据库用于开发和生产,只是为了确保 Git 可以发挥其魔力.
        • 在开发存储库上开发(仅).
        • 经过足够的测试后,请执行以下 2 个步骤:

        • Don't use one (the same) database for development and production, just to be sure that Git can do its magic.
        • Develop (only) on the development repository.
        • After enough tests, do the following 2 steps:

          1. root>git push 裸
          2. root/../production/root>git pull 裸

        • 启动开发服务器(仅):root>rails s Thin -p 4009
        • 和生产服务器(仅):root/../production/root>rails s Thin -e production -p 3009
        • 因此,我有更多的工作要做,从开发到生产阶段性变化,但我会消除那些一直存在的小烦恼.

          So as a result, I have a little more work to do, to stage changes from development to production, but I will eliminate those small irritations that were around all the time.

          这篇关于Windows 7 上 Rails 3.1 中本地使用的应用程序的最佳部署策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆