From b66e66caee803fe64878992a728fd724e96a027a Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 15 Sep 2024 05:37:22 -0300 Subject: [PATCH] Add ability to set file mode on unix socket --- nanoc.yaml.sample | 1 + rake/tasks/server.rake | 23 ++++++++++++++++------- share/al-quran.reflectslight.io/CHANGELOG | 6 ++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/nanoc.yaml.sample b/nanoc.yaml.sample index c3b2b7ed2..06c32125a 100644 --- a/nanoc.yaml.sample +++ b/nanoc.yaml.sample @@ -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 diff --git a/rake/tasks/server.rake b/rake/tasks/server.rake index c6ed11dd9..6243735e5 100644 --- a/rake/tasks/server.rake +++ b/rake/tasks/server.rake @@ -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 diff --git a/share/al-quran.reflectslight.io/CHANGELOG b/share/al-quran.reflectslight.io/CHANGELOG index fcc9a9d1c..377777bdd 100644 --- a/share/al-quran.reflectslight.io/CHANGELOG +++ b/share/al-quran.reflectslight.io/CHANGELOG @@ -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