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 base_url: https://al-quran.reflectslight.io
unix: unix:
path: path:
mode: ug=rw,o=
tcp: tcp:
host: 127.0.0.1 host: 127.0.0.1
port: 7777 port: 7777

View file

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

View file

@ -1,5 +1,11 @@
# -*- mode: org -*- # -*- 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 ** v0.9.1
**** Fix ~_opengraph.html.erb~ typos **** Fix ~_opengraph.html.erb~ typos