From 5d9144221faf76b9b12bec136bb9a5bf40fe7157 Mon Sep 17 00:00:00 2001 From: jon r Date: Fri, 25 Apr 2025 12:38:26 +0200 Subject: [PATCH 1/3] upgrade server to ruby 3 + add development dependency --- Gemfile | 2 ++ Gemfile.lock | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++-- site-web.rb | 2 +- slug-web.rb | 4 +-- 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 81a5bfc..615f4ae 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,5 @@ source "https://rubygems.org" gem "sinatra", "~> 4.1" gem "rackup", "~> 2.2" gem "puma", "~> 6.6" + +gem "solargraph", "~> 0.54.0", group: :development diff --git a/Gemfile.lock b/Gemfile.lock index a39621d..b4955ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,49 @@ GEM remote: https://rubygems.org/ specs: + ast (2.4.3) + backport (1.2.0) base64 (0.2.0) + benchmark (0.4.0) + diff-lcs (1.6.1) + jaro_winkler (1.6.0) + json (2.11.3) + kramdown (2.5.1) + rexml (>= 3.3.9) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + language_server-protocol (3.17.0.4) + lint_roller (1.1.0) logger (1.7.0) mustermann (3.0.3) ruby2_keywords (~> 0.0.1) nio4r (2.7.4) + nokogiri (1.18.8-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-musl) + racc (~> 1.4) + observer (0.1.2) + ostruct (0.6.1) + parallel (1.27.0) + parser (3.3.8.0) + ast (~> 2.4.1) + racc + prism (1.4.0) puma (6.6.0) nio4r (~> 2.0) + racc (1.8.1) rack (3.1.13) rack-protection (4.1.1) base64 (>= 0.1.0) @@ -18,6 +54,28 @@ GEM rack (>= 3.0.0) rackup (2.2.1) rack (>= 3) + rainbow (3.1.1) + rbs (3.9.2) + logger + regexp_parser (2.10.0) + reverse_markdown (3.0.0) + nokogiri + rexml (3.4.1) + rubocop (1.75.3) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.44.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.44.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sinatra (4.1.1) logger (>= 1.6.0) @@ -26,15 +84,49 @@ GEM rack-protection (= 4.1.1) rack-session (>= 2.0.0, < 3) tilt (~> 2.0) + solargraph (0.54.0) + backport (~> 1.2) + benchmark + bundler (~> 2.0) + diff-lcs (~> 1.4) + jaro_winkler (~> 1.6) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + logger (~> 1.6) + observer (~> 0.1) + ostruct (~> 0.6) + parser (~> 3.0) + rbs (~> 3.3) + reverse_markdown (>= 2.0, < 4) + rubocop (~> 1.38) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9, >= 0.9.24) + yard-solargraph (~> 0.1) + thor (1.3.2) tilt (2.6.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + yard (0.9.37) + yard-solargraph (0.1.0) + yard (~> 0.9) PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES puma (~> 6.6) rackup (~> 2.2) - sinatra (= 4.1.1) + sinatra (~> 4.1) + solargraph (~> 0.54.0) BUNDLED WITH - 2.4.20 + 2.6.8 diff --git a/site-web.rb b/site-web.rb index 338623f..6431c3a 100644 --- a/site-web.rb +++ b/site-web.rb @@ -8,7 +8,7 @@ def read Dir.new('sites').each do |site| next if site.match /^\./ - next unless Dir.exists?("sites/#{site}/pages") + next unless Dir.exist?("sites/#{site}/pages") next if (Date.today - File.mtime("sites/#{site}/pages").to_date).to_i > 365 size = Dir["sites/#{site}/pages/*"].size next if size < 10 diff --git a/slug-web.rb b/slug-web.rb index a104278..c8fb54a 100644 --- a/slug-web.rb +++ b/slug-web.rb @@ -6,7 +6,7 @@ def read Dir.new('sites').each do |site| next if site.match /^\./ - next unless Dir.exists?("sites/#{site}/pages") + next unless Dir.exist?("sites/#{site}/pages") Dir["sites/#{site}/pages/*"].each do |path| slug = (path.chomp.split(/\//))[3] @web[slug][:forks] += 1 @@ -25,4 +25,4 @@ def clean read clean -puts JSON.pretty_generate @web \ No newline at end of file +puts JSON.pretty_generate @web From 9d6432c97f25324ffdca4f78872621ee89cd6df6 Mon Sep 17 00:00:00 2001 From: jon r Date: Fri, 25 Apr 2025 12:55:47 +0200 Subject: [PATCH 2/3] add updating steps to linux demo --- demo/linux.md | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/demo/linux.md b/demo/linux.md index 9144381..3930566 100644 --- a/demo/linux.md +++ b/demo/linux.md @@ -33,9 +33,12 @@ export PATH="$GEM_HOME/bin:$PATH" Install the Ruby dependencies with: ```sh -bundle install +bundle install --without development ``` +This spares you from installing the `solargraph` development dependency for the +Ruby language server into your demo system. + ## Preparation The code assumes in many place from where it is made available. @@ -49,13 +52,6 @@ xargs -L1 sed 's/search.fed.wiki.org/search.federatedwiki.org/g' -i <<<"online.p server.rb" ``` -We also need a little upgrade, if we want to run from Ruby 3. - -```sh -xargs -L1 sed 's/Dir.exists/Dir.exist/' -i <<<"slug-web.rb -site-web.rb" -``` - You will need at least one seed site to start from. Additionally we prepare the retired store. @@ -245,3 +241,40 @@ systemctl reload caddy ``` The wiki is now available at . + +## Updating + +To update your search service, stop its runtime components, keep your modifications, +pull available changes, reapply your changes and boot up again. + +We'll walk you through the steps. + +1. Stop services + +```sh +systemctl --user stop wiki-search wiki +``` + +2. Keep local motifications + +```sh +git stash push +``` + +3. Pull remote motifications + +```sh +git pull +``` + +4. Restore local motifications + +```sh +git stash pop +``` + +5. Restart services + +```sh +systemctl --user start wiki-search wiki +``` From 5ced45449f3c7fcd4409ffcf555011bfdbfdd59e Mon Sep 17 00:00:00 2001 From: jon r Date: Fri, 25 Apr 2025 16:42:51 +0200 Subject: [PATCH 3/3] refresh linux demo example and fix mistakes --- demo/linux.md | 59 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/demo/linux.md b/demo/linux.md index 3930566..9f0a99b 100644 --- a/demo/linux.md +++ b/demo/linux.md @@ -41,8 +41,9 @@ Ruby language server into your demo system. ## Preparation -The code assumes in many place from where it is made available. -Adapt this location to your preference. +The code references the assumed public location of its endpoint and the endpoint +of the associated search wiki in many places. Adapt this location to your +preference. ```sh xargs -L1 sed 's/search.fed.wiki.org/search.federatedwiki.org/g' -i <<<"online.pl @@ -64,13 +65,17 @@ LANG="en_US.UTF-8" sh cron.sh Initially, this will take a lot of time. Wait for the process to complete. -Observe its doings for a current time window with e.g.: +Observe its doings for a current interval with e.g.: ```sh tail -f logs/Tue-1800 ``` -An exemplary initial run took four and a half hours. +An exemplary initial run took four and a half hours. It took ten runs of the +scheduled crawling to discover a stable set of federated domains. + +This allows [the logs](http://search.federatedwiki.org:3030/logs) to be used as +an activity monitor for each interval they cover. ## Running @@ -127,19 +132,22 @@ systemctl enable --user --now wiki-search The search is now available at . -Persist the user service with enabling linger mode: +Persist the user service across reboots with enabling user lingering: ```sh sudo loginctl enable-linger ubuntu ``` -### Proxy +### HTTP & HTTPS/ACME proxy Caddy -For serving the query interface using the default HTTP port, use: +For serving the query interface using the default HTTP port and separately via +HTTPS without issuing a redirect, you can use the caddy HTTP server. -``` +Modify the email address and domain to match your environment. + +```sh sudo cat < /etc/caddy/Caddyfile -> { +{ email acme@search.federatedwiki.org } @@ -147,10 +155,17 @@ http://query.search.federatedwiki.org, https://query.search.federatedwiki.org { reverse_proxy localhost:3030 } CADDYFILE -sudo systemctl restart caddy ``` -The query interface for the search is then also available at . +```sh +sudo systemctl reload caddy +``` + +The query interface for the search is then also available at + and +. + +The latter offers HTTPS-enabled wikis to use the search. ### Wiki @@ -162,7 +177,7 @@ This needs an additional installation of You can grab one at . -Copy the configuration example in place and fill the secret value. +Copy the configuration example and fill the secret value. ```sh cp config.json.example config.json @@ -172,7 +187,7 @@ cp config.json.example config.json ```sh sed 's/ROSTER search.fed.wiki.org:3030/ROSTER query.search.federatedwiki.org/' -i pages/federation-search -sed 's/ROSTER search.fed.wiki.org/ROSTER query.search.federatedwiki.org/' -i pages/federation-search +sed 's/ROSTER search.fed.wiki.org/ROSTER search.federatedwiki.org/' -i pages/federation-search xargs -L1 sed 's|http://search.fed.wiki.org:3030|http://query.search.federatedwiki.org|g' -i <<<"pages/federation-search pages/search-help" sed 's/"search.fed.wiki.org:3030"/"query.search.federatedwiki.org"/g' -i pages/federation-search @@ -180,7 +195,7 @@ sed 's/"search.fed.wiki.org:3030"/"query.search.federatedwiki.org"/g' -i pages/f -Now you can try to run the wiki. +You can now try to run the wiki. ``` wiki --data "${PWD}" --config "${PWD}/config.json" @@ -189,6 +204,8 @@ wiki --data "${PWD}" --config "${PWD}/config.json" If everything looks good when visiting , you can add the service to your service manager and reverse proxy. +### Persistent system service + ```sh systemctl edit --user --force --full wiki ``` @@ -216,15 +233,17 @@ WantedBy=default.target Tell your service manager about it: ```sh -systemctl --user daemon-reload +systemctl daemon-reload --user ``` And enable it: ```sh -systemctl --user enable --now wiki +systemctl enable --user --now wiki ``` +### Proxy configuration + Next add the service to the proxy: ```sh @@ -244,7 +263,7 @@ The wiki is now available at . ## Updating -To update your search service, stop its runtime components, keep your modifications, +To update your search service, stop its runtime, keep your modifications, pull available changes, reapply your changes and boot up again. We'll walk you through the steps. @@ -252,7 +271,7 @@ We'll walk you through the steps. 1. Stop services ```sh -systemctl --user stop wiki-search wiki +systemctl stop --user wiki-search wiki ``` 2. Keep local motifications @@ -276,5 +295,7 @@ git stash pop 5. Restart services ```sh -systemctl --user start wiki-search wiki +systemctl start --user wiki-search wiki ``` + +You're now up to date and benefitting from latest changes.