stack prosses

master
Izimic 2020-12-24 08:44:40 +01:00
parent 7332471fc5
commit 1d5750b770
1 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,7 @@
require "http/server"
require "option_parser"
require "fiber"
require "./payload.cr"
VERSION = 0.1
@ -57,6 +59,11 @@ if File.exists?(scriptfile_default) == false
exit 1
end
channel = Channel(Int32).new
spawn do
channel.send 0
end
server = HTTP::Server.new do |context|
if context.request.method != "POST" || context.request.path != "/"
context.response.status = HTTP::Status::NOT_FOUND
@ -82,7 +89,10 @@ server = HTTP::Server.new do |context|
scriptfile = path_project + "/../../../" + scriptfile_default
end
channel.receive
File.write(path_jsonfile, payload.content)
status = Process.run command: "zsh", args: [scriptfile], shell: true,
error: STDERR, output: STDOUT, chdir: path_project
end
@ -94,8 +104,14 @@ server = HTTP::Server.new do |context|
else
context.response.print "FAILURE"
end
spawn do
channel.send(0)
end
end
end
address = server.bind_tcp port
pp address
server.listen