Add ability to set file mode on unix socket

This commit is contained in:
0x1eef 2024-09-15 05:37:22 -03:00
parent 06ae1173b6
commit b66e66caee
3 changed files with 23 additions and 7 deletions

View file

@ -27,6 +27,7 @@ server:
base_url: https://al-quran.reflectslight.io
unix:
path:
mode: ug=rw,o=
tcp:
host: 127.0.0.1
port: 7777

View file

@ -1,19 +1,28 @@
# frozen_string_literal: true
cwd = File.realpath File.join(__dir__, "..", "..", ".")
desc "Start web server"
task :server, [:protocol] do |_t, args|
require "server"
nanoc = Ryo.from_yaml(path: File.join(cwd, "nanoc.yaml"))
h = args.to_h
p = h[:protocol] || "tcp"
n = File.basename(dirs.root)
n = File.basename(cwd)
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}]"
{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)
Process.setproctitle "rake server[#{p}] [#{n}]"
if p == "unix"
t = s.start(block: false)
unix = nanoc.server.unix
chmod(unix.mode, unix.path, verbose: false)
t.join
else
s.start(block: true)
end
rescue Interrupt
s.stop
end

View file

@ -1,5 +1,11 @@
# -*- mode: org -*-
** vNEXT
**** Add ability to set file mode in ~server.rake~
Add ability to set the file mode on unix socket.
Default: ~ug=rw,o=~
** v0.9.1
**** Fix ~_opengraph.html.erb~ typos