https://github.com/hellojukay/systemd-demo
This is a golang demo project to create a service by systemd,.
https://github.com/hellojukay/systemd-demo
golang service systemctl systemd
Last synced: 5 months ago
JSON representation
This is a golang demo project to create a service by systemd,.
- Host: GitHub
- URL: https://github.com/hellojukay/systemd-demo
- Owner: hellojukay
- Created: 2019-05-06T09:30:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-24T08:58:22.000Z (almost 6 years ago)
- Last Synced: 2025-07-25T05:30:48.512Z (11 months ago)
- Topics: golang, service, systemctl, systemd
- Language: Shell
- Size: 3.49 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# systemd-demo
a systemd demo project , write by golang ,a web servoice return current time string.
[](https://travis-ci.org/hellojukay/systemd-demo)
## How to install it
it will build main.go , and create now.service in `/lib/systemd/system/now.service`
```shell
sudo bash install.sh
```
## How to run it
after install now.service
```shell
systemctl start now.service
```
```shell
hellojukay@local systemd-demo (master) $ systemctl status now
● now.service - A web service get now time string
Loaded: loaded (/lib/systemd/system/now.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-05-06 17:52:35 CST; 5min ago
Main PID: 3052 (now)
Tasks: 6 (limit: 4915)
Memory: 5.4M
CGroup: /system.slice/now.service
└─3052 /usr/bin/now
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
```
run with special user
```shell
vagrant@ubuntu-bionic systemd-demo (master) $ ps aux | grep now
vagrant 3604 0.0 0.1 1008360 5420 ? Ssl 03:26 0:00 /usr/bin/now
vagrant 3866 0.0 0.0 14856 1004 pts/0 R+ 03:38 0:00 grep --color=auto now
```
access by curl
```shell
hellojukay@local systemd-demo (master) $ curl http://127.0.0.1:6000/now
2019-05-06 18:39:25
```
## Auto start at boot
it will auto start whill system started.
```shell
systemctl enable now
```