Update server.rake

This commit is contained in:
0x1eef 2024-06-21 04:37:44 -03:00
parent 97e282c1a2
commit f9e7bb6469
4 changed files with 30 additions and 9 deletions

View file

@ -51,7 +51,7 @@ GEM
rb-fsevent (0.11.2) rb-fsevent (0.11.2)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
ryo.rb (0.5.1) ryo.rb (0.5.5)
sequel (5.80.0) sequel (5.80.0)
bigdecimal bigdecimal
server.rb (0.2.2) server.rb (0.2.2)

View file

@ -1,4 +1,9 @@
require "bundler/setup" require "bundler/setup"
require "twenty/cli"
require "twenty/client"
require "twenty/server"
require "ryo"
require "ryo/yaml"
load "host/rake/tasks/schema.rake" load "host/rake/tasks/schema.rake"
load "host/rake/tasks/nanoc.rake" load "host/rake/tasks/nanoc.rake"

View file

@ -14,3 +14,10 @@ data_sources:
encoding: utf-8 encoding: utf-8
content_dir: src/ content_dir: src/
layouts_dir: src/layouts layouts_dir: src/layouts
server:
unix:
path: /tmp/github.com.0x1eef.twenty
tcp:
host: 127.0.0.1
port: 7777

View file

@ -1,11 +1,20 @@
desc "Run server" # frozen_string_literal: true
task :server, [:protocol] do |_, args|
require 'rbconfig' cwd = File.realpath File.join(__dir__, "..", "..", "..", "client")
cli = [RbConfig.ruby, "-rbundler/setup", "cli/bin/twenty", "up"] desc "Start web server"
h = args.to_h task :server, [:protocol] do |_t, args|
if h[:protocol] == "unix" nanoc = Ryo.from_yaml(path: File.join(cwd, "nanoc.yaml"))
Process.wait spawn(*cli, "--unix", "/tmp/twenty.freebsd.local") h = args.to_h
p = h[:protocol] || "tcp"
n = File.basename File.dirname(cwd)
Process.setproctitle "rake server[#{p}] [#{n}]"
if p == "unix"
Twenty::Command::Up
.new(["-u", nanoc.server.unix.path])
.run
else else
Process.wait spawn(*cli) Twenty::Command::Up
.new(["-b", nanoc.server.tcp.host, "-p", nanoc.server.tcp.port])
.run
end end
end end