def create
# exec('python')
Thread.new do
puts"exec"
exec('python3.7 -c "print(\"Ran a new command in thread\")"')
end
render json: {"message": "Successfully added image", "status": "200"}, status: :ok
end
after this code runs the server closes
Can anyone help me understand what is the problem?
I figured it out. I should use system
instead of exec
to run my command.
system
runs the command in a subshell.\\
so now the code becomes
system 'python3.7 -c "print(\"Ran a new command in thread\")"'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.