简体   繁体   English

流浪者工作流程-流浪者ssh,流浪者销毁,流浪者启动命令

[英]Vagrant Workflow - vagrant ssh, vagrant destroy, vagrant up commands

I am having some trouble understanding the vagrant workflow from their website. 我在从他们的网站了解无业游民的工作流程时遇到了一些麻烦。

I had previously been working on a project and had gone through the whole process of changing directory and setting up the vagrant box, etc. I had even run bundle install that installed all of the gems of the forked project I am working on. 我以前一直在从事一个项目,并且已经完成了更改目录和设置无用信息框的整个过程,等等。我什至运行过bundle install,它安装了我正在从事的分支项目的所有项目。 I configured the web server to work and was even able to go to see the project on my browser through the web server connection. 我将Web服务器配置为可以运行,甚至可以通过Web服务器连接在浏览器上查看项目。

Later on I had to go get dinner so I did 后来我不得不去吃晚饭,所以我做了

vagrant destroy

When I returned, in the same directory I ran 当我返回时,在同一目录中运行

vagrant up

Then I did 然后我做了

vagrant ssh

followed by 其次是

cd /vagrant

when I get here I run 当我到达这里时,我跑步

rails s

and I get the following error: 我收到以下错误:

The program 'rails' is currently not installed.  You can install it by typing:
sudo apt-get install rails

Shouldn't running vagrant up remember all of the work I had previously done? 难道流浪汉不记得我以前做过的所有工作吗? Or do I have to restart from scratch and rebuild all of my gems every time? 还是我必须从头开始重新启动并每次都重建所有宝石? Am I missing something? 我想念什么吗?

vagrant destroy does literally what the command says - destroys started up VM, completely with disc images. vagrant destroy确实执行命令所说的内容-完全使用磁盘映像销毁启动的VM。 Every change (ie installation of software, results of running bundle install , etc) is lost, beyond the changes that happened in /vagrant directory. 除了/vagrant目录中发生的更改之外,所有更改(即软件bundle install ,运行bundle install结果等)都将丢失。

If you want to just stop the VM without destroying disc images - you should use vagrant halt instead (or just power off VM as you would do with a real server - ie by issuing poweroff ). 如果您只是想停止VM而又不破坏磁盘映像,则应该改用vagrant halt (或者像在真实服务器上一样关闭VM的电源-即发出poweroff )。

The general workflow for deploying a vagrant-powered VM outlined in documentation is that you distribute Vagrantfile along with your sources that includes provisioning section ( config.vm.provision ) which does the stuff you've described - installation of additional software not bundled in a box image (ie Rails, gems), setting up the databases, etc. It can be implemented in several ways, starting from just running a simple shell script (with sequential commands to execute), up to using high-profile configuration management systems like Chef , Puppet , CFEngine , Ansible , etc. 文档中概述的部署由Vagrantfile驱动的VM的一般工作流程是,您分发Vagrantfile及其源代码,其中包括配置部分( config.vm.provision ),该部分完成您描述的工作-安装未捆绑在服务器中的附加软件盒映像(即Rails,gem),设置数据库等。它可以通过多种方式实现,从仅运行简单的Shell脚本(具有要执行的顺序命令)到使用诸如ChefPuppetCFEngineAnsible

Temporary break (like going for dinner) generally does not require even halting a VM, less destroying it. 临时休息(例如去吃饭)通常不需要停止VM,也不需要破坏VM。 Even a full-fledged VM running under VirtualBox / VMware / KVM with a single-user Rails application hardly consumes lots of resources to worry about. 即使使用单用户Rails应用程序在VirtualBox / VMware / KVM下运行的成熟VM也几乎不会消耗大量资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM