Вопрос

I am having following code in my model methods which i am calling from my controller.

Kernel.system"curl -H "Content-Type:application/json" -d "{\"party\":{\"lock_version\":\"0\",\"party_type\":\"Customer\",\"name\":\"xxxxx\",\"sub_type\":\"\",\"description\":\"\",\"contacts_attributes\":{\"1\":{\"name\":\"Jy\",\"email\":\"xxxx@gmail.com\",\"is_default\":\"true\",\"_destroy\":\"0\"}}}}" "http://localhost:3000/company/customers?auth_token=BhD7P6sXkHkNwVVXx3TF""

when the above code execute,on console i can see.

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 202 0 0 0 202 0 0 --:--:-- 0:04:13 --:--:-- 0

but the above process is keep going on.When i shutdown my server using CTRL+c i can see the following lines on my console.

Started POST "/company/customers?auth_token=BhD7P6sXkHkNwVVXx3TF" for 127.0.0.1 at Mon Nov 26 05:24:13 +0000 2012 Processing by PartiesController#create as JSON Parameters: {"party"=>{"lock_version"=>"0", "party_type"=>"Customer", "name"=>"xxxxx", "sub_type"=>"", "description"=>"", "contacts_attributes"=>{"1"=>{"name"=>"Jy", "email"=>"xxxx@gmail.com", "is_default"=>"true", "_destroy"=>"0"}}}, "auth_token"=>"BhD7P6sXkHkNwVVXx3TF", "party_type"=>"Customer"} WARNING: Can't verify CSRF token authenticity

Which means that my customer is successfully using curl.

But why do i need to shutdown my server and then restart inorder to see the result of curl command?Is there any solution for this problem or am i doing something wrong?

Please help me,

Thanks.

Это было полезно?

Решение

I have got answer to my question. I just had to use -m command which limit the execution time for command.

like

Kernel.system"curl -m 3 -H "Content-Type:application/json" -d "{\"party\":{\"lock_version\":\"0\",\"party_type\":\"Customer\",\"name\":\"xxxxx\",\"sub_type\":\"\",\"description\":\"\",\"contacts_attributes\":{\"1\":{\"name\":\"Jy\",\"email\":\"xxxx@gmail.com\",\"is_default\":\"true\",\"_destroy\":\"0\"}}}}" "http://localhost:3000/company/customers?auth_token=BhD7P6sXkHkNwVVXx3TF""

Which will run for 3 sec...so now i do not need to shutdown my server.:-)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top