Skip to content

About

A simple playground repository for learning how to run and manage Linux services using systemd. The goal of this project is not to build a production-ready application, but to understand the fundamentals of linux

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

Systemd Playground

A simple playground repository for learning how to run and manage Linux services using systemd. The goal of this project is not to build a production-ready application, but to understand the fundamentals of:

  • Creating a systemd service unit
  • Managing services with systemctl
  • Viewing logs with journalctl
  • Organizing deployment-related files inside a repository

Project Structure

.
├── bin/
│   └── hello-world
├── etc/
│   └── systemd/
│       └── system/
│           └── hello-world.service
├── go.mod
├── main.go
└── readme.md

Directory Overview

Path Description
main.go Sample Go application
bin/ Compiled binaries
etc/systemd/system/ Systemd unit files managed inside the repository
readme.md Project documentation

Application

The sample application:

  • Starts an HTTP server
  • Returns Hello World
  • Writes a log message every 5 seconds

This application exists only to provide a process that can be managed by systemd.

How to create a unit systemd service

Build the application

Compile the application:

go build -o bin/hello-world .

Check the application working correctly

Run it manually:

./bin/hello-world

Copy a service configuration into /etc/systemd/system/

sudo cp etc/systemd/system/hello-world.service /etc/systemd/system/

Copy binaries file to /usr/local/bin/hello-world

sudo cp bin/hello-world /usr/local/bin/hello-world

Copy env file

sudo cp /path-to-your-project/.env /etc/default/hello-world

Reload daemon

sudo systemctl daemon-reload

Start the service

sudo systemctl start hello-world

Check the service status

sudo systemctl status hello-world

Learning Objectives

After completing this playground, you should understand:

  • What a systemd service is
  • How Linux services are started and supervised
  • How automatic restart policies work
  • How to inspect service logs

About

A simple playground repository for learning how to run and manage Linux services using systemd. The goal of this project is not to build a production-ready application, but to understand the fundamentals of linux

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages