-
Notifications
You must be signed in to change notification settings - Fork 0
added systemd example to README #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,3 +85,74 @@ All routes are served over HTTPS under the `/fmsgid` path. | |
| | `GET` | `/fmsgid/:address` | Lookup an fmsg address and return its details including display name, quotas, and usage. The address must be in fmsg format (`@[email protected]`). Returns `AddressDetail` JSON on success, `400` if the address is invalid, `404` if not found. | | ||
| | `POST` | `/fmsgid/send` | Record a send transaction. Accepts an `AddressTx` JSON body with `address`, `ts` (timestamp), and `size`. | | ||
| | `POST` | `/fmsgid/recv` | Record a receive transaction. Accepts an `AddressTx` JSON body with `address`, `ts` (timestamp), and `size`. | | ||
|
|
||
| ### systemd | ||
|
|
||
| An example systemd service to run fmsgid as a service on startup | ||
|
|
||
| ASSUMES: | ||
| * Directory `/opt/fmsgid` has been created and contains built executable: `fmsgid` | ||
| * Text file `/opt/fmsgid/env` exists containing environment variables (example below) | ||
| * User `fmsg` has been created and has | ||
| - read and execute permissions to `/opt/fmsgid/`, e.g. with `chown -R fmsg:fmsg /opt/fmsgid` after `mkdir /opt/fmsgid` | ||
| - write permissions to `/opt/fmsgid` and to the path specified by `FMSGID_CSV_FILE` if it is outside `/opt/fmsgid` | ||
|
|
||
| `/etc/systemd/system/fmsgid.service` | ||
|
|
||
| ``` | ||
| [Unit] | ||
| Description=fmsgid HTTP API | ||
| After=network-online.target | ||
| Wants=network-online.target | ||
|
|
||
| [Service] | ||
| Type=simple | ||
|
|
||
| User=fmsg | ||
| Group=fmsg | ||
|
|
||
| EnvironmentFile=/opt/fmsgid/env | ||
|
|
||
| ExecStart=/opt/fmsgid/fmsgid | ||
| WorkingDirectory=/opt/fmsgid | ||
|
|
||
| Restart=on-failure | ||
| RestartSec=3 | ||
|
|
||
| # --- Filesystem access --- | ||
| ReadWritePaths=/opt/fmsgid | ||
| PrivateTmp=true | ||
|
|
||
| # --- Hardening --- | ||
| NoNewPrivileges=true | ||
| PrivateTmp=true | ||
| ProtectSystem=strict | ||
| ProtectHome=true | ||
|
|
||
| # --- Logging --- | ||
| StandardOutput=journal | ||
| StandardError=journal | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| ``` | ||
|
|
||
| ### env | ||
|
|
||
| ``` | ||
| GIN_MODE=release | ||
| FMSGID_PORT=8080 | ||
| FMSGID_CSV_FILE=addresses.csv | ||
|
|
||
| PGHOST=127.0.0.1 | ||
| PGPORT=5432 | ||
| PGUSER= | ||
| PGPASSWORD= | ||
| PGDATABASE=fmsgid | ||
| ``` | ||
|
|
||
| ``` | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable fmsgid | ||
| sudo systemctl start fmsgid | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExecStart=/opt/fmsgid/fmsgid 0.0.0.0suggests the binary accepts a bind-address argument, butsrc/fmsgid.godoesn't parse CLI args and Gin’sRun(":"+port)already binds on all interfaces by default. Consider removing0.0.0.0(or documenting the actual supported way to configure the bind address if one exists).