Skip to content

Instantly share code, notes, and snippets.

@mark-kubacki
Last active June 28, 2017 16:20
Show Gist options
  • Save mark-kubacki/506102fbf3025dd143ce9fe6ec99a175 to your computer and use it in GitHub Desktop.
Save mark-kubacki/506102fbf3025dd143ce9fe6ec99a175 to your computer and use it in GitHub Desktop.
godoc and systemd
[Unit]
Description=updates Golang's documentation index
ConditionFileNotEmpty=!/usr/share/go-1.6/godoc_index.db
ConditionACPower=true
AssertDirectoryNotEmpty=/usr/share/go-1.6
[Service]
Restart=on-failure
ExecStart=/usr/bin/godoc \
-goroot /usr/share/go-1.6 \
-index -index_files /usr/share/go-1.6/godoc_index.pre -write_index \
-notes XXX
ExecStopPost=/bin/mv /usr/share/go-1.6/godoc_index.pre /usr/share/go-1.6/godoc_index.db
PrivateTmp=true
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
ReadWriteDirectories=/usr/share/go-1.6
CapabilityBoundingSet=
AmbientCapabilities=
NoNewPrivileges=true
[Install]
WantedBy=default.target
[Unit]
Description=starts Golang's doc server when the index is ready
After=godoc-create-index.service
[Path]
PathExists=/usr/share/go-1.6/godoc_index.db
[Install]
WantedBy=multi-user.target
[Unit]
Description=shows Golang's documentation
After=network-online.target godoc-update-index.service
Wants=network-online.target godoc-update-index.service
ConditionFileNotEmpty=|/usr/share/go-1.6/godoc_index.db
ConditionACPower=|true
[Service]
Restart=on-failure
Environment=GOMAXPROCS=2
User=nobody
Group=nogroup
ExecStart=/usr/bin/godoc -http=:6060 \
-goroot /usr/share/go-1.6 \
-index -index_files=/usr/share/go-1.6/godoc_index.db \
-notes XXX
ExecReload=/bin/kill -USR1 $MAINPID
PrivateTmp=true
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
ReadWriteDirectories=/usr/share/go-1.6
;CapabilityBoundingSet=CAP_NET_BIND_SERVICE
;AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=
AmbientCapabilities=
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
Also=godoc.path
Also=godoc-create-index.service
@mark-kubacki
Copy link
Author

systemctl daemon-reload

systemctl enable godoc-create-index.service godoc.path
systemctl start godoc-create-index.service godoc.path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment