transitioning this site from screen to systemd

This website has been one of my first explorations into doing any sort of web programming, and as result, has taught me a lot about different computing concepts from networking to encryption to system processes. At the start, I was running this service pretty simply over https. Since the content is largely static and doesn't really include any sensitive information, adding support for TLS to accommodate https wasn't a high priority.

The site uses the Rocket web server, which basically requires typing in $ cargo run --release into the site directory, which will use the specified compilation profile to bind to the given port. For http-only, this is usually Port 80; for https, Port 443. However, Rocket doesn't automatically run in the background, so if you want to exit your SSH session.

I tested this first using a Odroid-N2+1 that I use as test machine in my homelab. However, as mentioned on my site's About page, I host this site using a Digital Ocean droplet, which has a different directory structure from the Armbian user profile that I'm using on the N2+, where the standard user files are located a /home/user. Instead, the Droplet has files (by default) at /root. Keep this in mind when switching configuration paths between the test and "production" (everything's relative, right?) environments.

The file described the website's executable as a service, with a syntax as described here, with a good introductory article to using systemd here.


  # A file with this information goes at /etc/systemd/system/site.service
  [Unit]
  Description=Website (cmoran.xyz)
  After=network.target
  StartLimitIntervalSec=1

  [Service]
  Type=simple
  Restart=always
  RestartSec=1
  User=root
  WorkingDirectory=/root/site
  # ExecStart requires an absolute path
  ExecStart=/root/site/target/release/site

  [Install]
  WantedBy=multi-user.target

From there, we can


 # Reload the systemd service configuration files
 $ sudo systemctl daemon-reload
 $ sudo systemctl enable site.service
 $ sudo systemctl restart site.service

During this process, I like to keep an eye on what's actually happening in the system. The easiest way to do this is through journalctl using the command


 # Move to end (-e) of the file and follow (-f)
 $ journalctl -e -f

but most of the important information will also appear if you use the command


 # Follow (-f) the tail end of the syslog
 $ sudo tail -f /var/log/syslog 


  1. The N2+ a great little machine, but if you're in North America and considering a purchase, I'd suggest using Ameridroid instead of Hardkernel. I at one point purchased an Odroid-C4 directly from Hardkernel which quickly developed some hardware issues. Getting an RMA notice from Hardkernel didn't take too long, but the shipping cost to/from the United States to their factory would have been over twice the cost of buying a new board. On the other hand, I haven't any issues with Ameridroid-purchased boards, but their customer support for things like making small order modifications has been really great, and I've been a pretty happy customer for a number of SBC-related part orders.