Skip to main content
  1. Tech/

A quick script to build and deploy hugo site on VPS

·2 mins

I had been using GitHub and Netlify for this site but lack of some features such as access to server logs finally got too much. So I decided to move this blog to my VPS.

One thing I really love about using Github is CI/CD and Github Actions. But I wanted something even simpler with less dependencies. So I decided to use a simple bash script to build and deploy the site.

Here is the script:

#!/bin/bash

git add .
git commit -m "Commit before deployment"
git push

rm -rf public/ && hugo

rsync -avz --verbose --delete public/ USER@HOST:/path/to/deploy/dir

ssh USER@HOST << 'ENDSSH'
  chown -R USER:www-data /path/to/deploy/dir
  chmod -R 750 /path/to/deploy/dir
ENDSSH

View server Logs
#

I am moving away from 3rd party analytics due to privacy concerns. But it is useful to know that people are visiting my site and what they are finding useful. So I use server logs to get this information.

First, make sure each virtual host has its own log file. Update your virtual host configuration file to include the following lines:

ErrorLog /var/log/apache2/example.com-error.log
CustomLog /var/log/apache2/example.com-access.log combined

Then the simplest way to look at logs is to use GoAccess. I just view stats in terminal with:

goaccess access.log -c

It doesn’t keep history but it is good enough for me.

Related

undefined method xxxxx' for #< Hash:0x00000 >

·1 min
This error in our Rails application drove me crazy. The error was like this: undefined method xxxxxx' for #<Hash:0x000000001234> The problem was that I was calling a method like this: a_method(var: var) And the method definition was like def a_method(var: var) which resulted in something called variable shadowing and caused clash between variable passed in the method and local variable being defined. The fix was to change method definition to def a_method(var:)

Script inherits from native type 'RigidBody2D', so it can't be assigned to an object of type: 'Node2D'

·1 min
Getting this error while following this tutorial in Godot v4.0.1. In my case, I had added Node2D. The fix was to right-click on the problem node under Scene and click Make Scene Root. And then delete Node2D. Here is what diff looked like: diff --git a/2d-game-tutorial/Mob.tscn b/2d-game-tutorial/Mob.tscn index 9eb1630..e720d7f 100644 --- a/2d-game-tutorial/Mob.tscn +++ b/2d-game-tutorial/Mob.tscn @@ -48,20 +48,18 @@ animations = { radius = 36.0 height = 100.0 -node name="Mob" type="Node2D"] -script = ExtResource("1_73gb4") - -node name="RigidBody2D" type="RigidBody2D" parent="."] +node name="RigidBody2D" type="RigidBody2D"] collision_mask = 0 gravity_scale = 2.66454e-15 +script = ExtResource("1_73gb4") -node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="RigidBody2D"] +node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] scale = Vector2(0.75, 0.75) sprite_frames = SubResource("SpriteFrames_c1yjy") animation = &"walk" -node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"] +node name="CollisionShape2D" type="CollisionShape2D" parent="."] rotation = 1.5708 shape = SubResource("CapsuleShape2D_h1pjc") -node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="RigidBody2D"] +node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]

How much can you really get out of a 4$ VPS?

·1 min
I am a big fan of cheap VPSs. I start many personal projects, bring up a VPS, play around and then wipe it. Never have to worry about accidentally running up a bill in 100s or 1000s of dollars. I run this blog on a $4 server. So this was interesting to read how far can a cheap VPS go.