al-quran.reflectslight.io/rake/tasks/server.rake

22 lines
572 B
Ruby
Raw Normal View History

2024-06-19 23:36:03 +02:00
# frozen_string_literal: true
2024-06-21 03:12:19 +02:00
cwd = File.realpath File.join(__dir__, "..", "..", ".")
2024-06-19 22:56:38 +02:00
desc "Start web server"
task :server, [:protocol] do |_t, args|
require "server"
2024-06-21 03:12:19 +02:00
nanoc = Ryo.from_yaml(path: File.join(cwd, "nanoc.yaml"))
2024-06-19 22:56:38 +02:00
h = args.to_h
p = h[:protocol] || "tcp"
2024-06-21 03:12:19 +02:00
n = File.basename(cwd)
2024-06-19 22:56:38 +02:00
o = if p == "unix"
2024-06-19 23:36:03 +02:00
{unix: nanoc.server.unix.path}
else
{host: nanoc.server.tcp.host, port: nanoc.server.tcp.port}
end
2024-06-19 22:56:38 +02:00
Process.setproctitle "rake server[#{p}] [#{n}]"
s = Server.dir(nanoc.output_dir, o)
s.start(block: true)
rescue Interrupt
s.stop
end