Created
July 3, 2017 17:31
-
-
Save cstockton/ac9a95f865607d2b5a2041ba5824eb94 to your computer and use it in GitHub Desktop.
This file contains 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
[Unit] | |
Description=ServiceName | |
Documentation=https://example.com/doc.txt | |
After=network-online.target | |
Wants=network-online.target systemd-networkd-wait-online.service | |
[Service] | |
Restart=on-failure | |
PermissionsStartOnly=true | |
User=programusername | |
Group=programusername | |
ExecStartPre=/sbin/setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/programname | |
ExecStart=/usr/local/bin/programname -flag 443 | |
[Install] | |
WantedBy=multi-user.target |
This file contains 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
#!/bin/bash | |
scp programname.service [email protected]:/etc/systemd/system/ | |
scp $GOPATH/bin/programname [email protected]:/usr/local/bin/ | |
ssh [email protected] | |
sudo su - # pwd: /root | |
# make sure this matches the programusername in service | |
# and DOES NOT start with a digit. | |
groupadd programusername | |
useradd -g programusername programusername | |
chmod g-w /home/programusername/ | |
chmod 644 /etc/systemd/system/programname.service | |
chmod 700 /usr/local/bin/programname | |
# If you need to run on port 443 | |
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/programname | |
systemctl daemon-reload | |
systemctl start programname.service | |
systemctl enable programname.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment