Add rake/tasks/server.rake
This commit is contained in:
parent
1399039985
commit
8f3a245f9a
2 changed files with 21 additions and 18 deletions
19
Rakefile.rb
19
Rakefile.rb
|
@ -4,8 +4,6 @@ require "bundler/setup"
|
|||
require "ryo"
|
||||
require "yaml"
|
||||
|
||||
##
|
||||
# Rake tasks
|
||||
begin
|
||||
load "rake/tasks/deploy.rake"
|
||||
rescue LoadError
|
||||
|
@ -15,20 +13,5 @@ load "rake/tasks/format.rake"
|
|||
load "rake/tasks/nanoc.rake"
|
||||
load "rake/tasks/t.rake"
|
||||
load "rake/tasks/ci.rake"
|
||||
|
||||
desc "Start HTTP server"
|
||||
task :server, [:protocol] do |_t, args|
|
||||
require "server"
|
||||
nanoc = Ryo.from(YAML.load_file("./nanoc.yaml"))
|
||||
h = args.to_h
|
||||
o = if h[:protocol] == "unix"
|
||||
{unix: nanoc.server.unix.path}
|
||||
else
|
||||
{host: nanoc.server.tcp.host, port: nanoc.server.tcp.port}
|
||||
end
|
||||
s = Server.dir(nanoc.output_dir, o)
|
||||
s.start(block: true)
|
||||
rescue Interrupt
|
||||
s.stop
|
||||
end
|
||||
load "rake/tasks/server.rake"
|
||||
task default: "nanoc:build"
|
||||
|
|
20
rake/tasks/server.rake
Normal file
20
rake/tasks/server.rake
Normal file
|
@ -0,0 +1,20 @@
|
|||
desc "Start web server"
|
||||
task :server, [:protocol] do |_t, args|
|
||||
require "yaml"
|
||||
require "ryo"
|
||||
require "server"
|
||||
nanoc = Ryo.from(YAML.load_file("./nanoc.yaml"))
|
||||
h = args.to_h
|
||||
p = h[:protocol] || "tcp"
|
||||
n = File.basename File.realpath(File.join(__dir__, "..", "..", "."))
|
||||
o = if p == "unix"
|
||||
{unix: nanoc.server.unix.path}
|
||||
else
|
||||
{host: nanoc.server.tcp.host, port: nanoc.server.tcp.port}
|
||||
end
|
||||
Process.setproctitle "rake server[#{p}] [#{n}]"
|
||||
s = Server.dir(nanoc.output_dir, o)
|
||||
s.start(block: true)
|
||||
rescue Interrupt
|
||||
s.stop
|
||||
end
|
Loading…
Reference in a new issue