【发布时间】:2014-07-31 07:16:46
【问题描述】:
我正在使用 Rails 4,我想在编辑控制器后执行 Python 脚本。
我已经完成了:
if @a_serverconfiguration.update(a_serverconfiguration_params)
format.html { redirect_to @a_serverconfiguration, notice: 'Device configuration was successfully updated. Next time, you have to access to new ip configuration. Rebooting device, this would take a while...' }
format.json { render :show, status: :ok, location: @a_serverconfiguration }
Thread.new do
exec "sudo python /home/pi/Desktop/starting.py"
end
else
format.html { render :edit }
format.json { render json: @a_serverconfiguration.errors, status: :unprocessable_entity }
end
end
但是在执行 python 脚本之前我看不到我的显示页面。此脚本在 10 秒后重新启动,因此当用户更新控制器时,看不到消息“设备配置已成功更新。下次,您必须访问新的 ip 配置。重新启动设备,这将需要一段时间......'。 Webrick 等待 10 秒后下线。
我已经尝试过使用 Webrick 和 Thin,两者都做同样的事情。
【问题讨论】:
标签: python ruby-on-rails exec thin webrick