是否可以通过向Web服务器发送请求来重启系统?这是我到目前为止所尝试的内容,但不断收到错误(Plug.Conn.NotSentError) a response was neither set nor sent from the connection
。
defmodule App.Web.SystemController do
use App.Web, :controller
def system(conn, %{"command" => command}) do
"sudo shutdown -r now" |> String.to_char_list |> :os.cmd
conn
end
end
我正在使用RPI上的本地服务器,并且希望在界面中有一个自动重新启动服务器的按钮。使用elixir关闭服务器的正确方法是什么?
我还在想我可以编写一个bash脚本,而只是调用它,但不确定它是否会对webserver产生任何负面影响。任何建议,建议赞赏!
我从终端获得错误:
Request: POST /api/v1/system_power/
** (exit) an exception was raised:
** (Plug.Conn.NotSentError) a response was neither set nor sent from the connection
(plug) lib/plug/adapters/cowboy/handler.ex:42: Plug.Adapters.Cowboy.Handler.maybe_send/2
(plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) /Users/user/app/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4