在进行vagrant up provider = rackspace时脚本完全完成之前没有输出

时间:2022-08-23 17:56:07

i am using vagrant to spin up some servers in a rackspace / open stack cluster. I am using the vagrant rackspace plugin ( https://github.com/mitchellh/vagrant-rackspace ).

我正在使用vagrant在机架空间/开放堆栈集群中启动一些服务器。我正在使用vagrant rackspace插件(https://github.com/mitchellh/vagrant-rackspace)。

My provisioning script executes and works fine -- with one inconvenience, however: I don't see any output from the script until the very end. Somehow all script output seems like it is being buffered, and I do see it.. but not until the script has complete terminated.

我的配置脚本执行并且工作正常 - 但有一个不便之处:直到最后我才看到脚本的任何输出。不知何故,所有脚本输出似乎都被缓冲了,我确实看到了..但是直到脚本完全终止。

I have a workaround which is to 'tee' the output of all the scripts i run to a file which i can look at (during provisioning) if i use the rackspace console to login.. But it would be even better if the output scrolled by immediately as it was produced, rather than being buffered and dumped out at the end.

我有一个解决方法是将我运行的所有脚本的输出“发送”到我可以查看的文件(在配置期间),如果我使用rackspace控制台登录..但如果输出滚动会更好在生产时立即生产,而不是在最后进行缓冲和倾倒。

[ note - i also filed a bug with the developer, and i will update this thread if i get an answer there. note2: i tried this with :keep_color => true and without that parameter.. same result: no output until the end).

[注意 - 我也向开发者提交了一个错误,如果我在那里得到答案,我会更新这个帖子。 note2:我试过这个:keep_color => true而没有那个参数..结果相同:直到结束才输出)。

To reproduce, please use your rackspace credentials instead of the dummy ones below. Then run vagrant up provider=rackspace. You will see all of the output appear at once (rather then seeing the message "sleeping 40 secs", followed by a delay, then another message.)

要重现,请使用您的rackspace凭据,而不是下面的虚拟凭据。然后运行vagrant up provider = rackspace。您将看到所有输出立即显示(而不是看到消息“睡眠40秒”,然后是延迟,然后是另一条消息。)

    Vagrant.configure("2") do |config|

             config.vm.box = "dummy"
             config.ssh.pty = true          # work around issue where sudo requires tty


            config.vm.provision :shell,
              :keep_color => true,
              :inline=> ' ( echo sleeping 40 secs ; sleep 40 ; echo sleep again for 40 secs ; sleep 40 ) | tee /tmp/out'


             config.ssh.private_key_path = "./id_rsa"

             config.vm.provider :rackspace do |rs|
                rs.username        = "bozo"
                rs.api_key         = "the-clown"
                rs.flavor          = /1 GB Performance/
                rs.image           = "bfa5783c-e40e-4668-adc1-feb0ae3d7a46"

                rs.public_key_path = "./id_rsa.pub"
                rs.rackspace_region = :dfw
             end

    end

1 个解决方案

#1


0  

I don't have a Rackspace Account but maybe is the same Problem as:

我没有Rackspace帐户,但可能与以下问题相同:

How can I use "puts" to the console without a line break in ruby on rails?

如何在轨道上的ruby中没有换行符时使用“puts”到控制台?

Try adding this to your Vagrantfile:

尝试将此添加到您的Vagrantfile:

$stdout.sync = true
$stderr.sync = true

#1


0  

I don't have a Rackspace Account but maybe is the same Problem as:

我没有Rackspace帐户,但可能与以下问题相同:

How can I use "puts" to the console without a line break in ruby on rails?

如何在轨道上的ruby中没有换行符时使用“puts”到控制台?

Try adding this to your Vagrantfile:

尝试将此添加到您的Vagrantfile:

$stdout.sync = true
$stderr.sync = true