惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MyScale Blog
MyScale Blog
U
Unit 42
M
MIT News - Artificial intelligence
小众软件
小众软件
P
Proofpoint News Feed
雷峰网
雷峰网
L
LangChain Blog
S
SegmentFault 最新的问题
腾讯CDC
F
Fortinet All Blogs
A
About on SuperTechFans
WordPress大学
WordPress大学
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
Recent Announcements
Recent Announcements
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog

Null's blog

Switching to harper-ls Switching to harper-ls Thinking long term; A weird story Thinking long term; A weird story The case against WebUsb The case against WebUsb Why Wayland is the future. Why Wayland is the future. Debugging a crashed kernel on opensuse Debugging a crashed kernel on opensuse Envisioning a future python Envisioning a future python server update, A new name, comments via firefish and lightmode server update, A new name, comments via firefish and lightmode A look back at the webserver Webserver Updates Webserver Updates Migrating to a custom blogging backend Migrating to a custom blogging backend Nixops to Deploy-rs Nixops to Deploy-rs Archlinux with secureboot on a nvidia machine Archlinux with secureboot on a nvidia machine Nixops the future of deploying applications? Nixops the future of deploying applications? Installing NixOS on a Running Install of Arch Linux Installing NixOS on a Running Install of Arch Linux Why you should use Neovim Why you should use Neovim Flatpaking Github Desktop Pt2: GPG
A look back at the webserver
nullrequest · 2023-03-21 · via Null's blog

If you have read this blog you'll know I'm moving from hugo to a custom webserver. I'm happy to say the new blog is ready to be switched over too, it currently is on https://new.nullrequest.com and this weekend will be moved to https://nullrequest.com. I'm currently writing this post in the new editor. Its really a big upgrade over hugo for me. I learned a lot writing the backend code for the blog as well as the frontend. HTML/CSS has never been my fortay so I always fell back to bootstrap and never really got into writing a lot of my code(I still use <center> to center divs). So actually making a blog I'm proud of using something like tailwind and custom css has been a big confidence boost for me. I'd like to talk about how i started with my writing the server and how it has changed over time.

How it began

I can't talk about the architecture of this without going back to the start. When I started I tried to make a fs->html server that would read markdown files and return them render neatly in HTML. While this started out fast it quickly ran into rough edges. For example data about what posts where present, what tags they had and when then were published were stored in the font matter. My solution was to preload everything into a json file like bellow.

{
  "posts": [
		{
			"title": "Archlinux with secureboot on a nvidia machine",
			"date": "2022-03-26T19",
			"tags": ["arch", "linux","secureboot", "nvidia"],
			"draft": "false"
		}
	]
}

This resulted in a very fast but also very restricted server, every time I wanted to update a post, add or delete a post I would have to run a tool to regenerate the json and finally restart the webserver. While it was fast and different to the bog static site and it was a webserver( a goal i wanted) I never intended to replace the blog with it, more at the time experiment with a new architecture that might lead to better performance which I was facing a massive issue with. At the time I was running nginx on a Core2Duo, nginx is a server then benefits from more threads, for its workers in my case I old had 2 threads and the ethernet port was old meaning it was capped at 1mb/s. Which limited the initial response time(over a second at the worst). So this was supposed to fix that issue. Looking back it would have been a upgrade if I didn't stick it behind nginx which clearly didn't like running on a Core2Duo.

Auth, the first steps

At the time I thought about splitting out the UI to a frontend written in svelte and serving it using nginx while using the /api sub header to send requests to the webserver, after bouncing between svelte, vue and astro as frontend ui's never really getting a grasp on how to use any I ended up using just plain HTML/CSS and JS which turned out to be the best choice since now I could drop nginx from the stack. Before I switched to a html ui I wanted to add a post editor to write (at the time I still wanted to write a file for every post). My first goal was to get auth in place to make sure I was the only one who could write posts. Thus I made some choices early on, postgresql as a db, dropping a registration url and sifting comments to a 3rd party solution.

As time progressed with the project I made the choice to store posts in the postgresql(a very good choice which lead to better speeds and less code complexity). I thought about serving static assets from ngnix but eventually settled on having that inside my server, I may consider setting up a reverse proxy to serve only static files but as of now I have no need to use a reverse proxy as cloudflare already acts as reverse proxy for me, adding another proxy just leads to larger latencies and worse performance for people using the site.

The future

The last step to be ready to switch my blog to my old blog was to finish writing tag support but several failed attempts eventually lead to finally with the help of a few friends a working tag system that allows me to reverse look up posts by tag and to allow me to be one to one with my old blog allowing me to easily switch to my new blog. The only thing holding me back is the fear everything will break and I will have to figure out how to fix it myself. As time goes on I'll be adding functionality like webmentions(when I figure out how they work), Some form of light mode because some people like it???? like I have not met anyone who really uses light mode outside of a joke. Well that's all for now

-- This is nullrequest signing off