deploy golang service as ubuntu systemd service
This guide describes how to manually install deployd as a systemd service.
- Linux x86_64 (amd64)
- systemd
- Root or sudo access
Deployd is installed under:
/opt/deployd/current/
Environment files are stored in:
/etc/deployd/env/
The service definition is:
/etc/systemd/system/deployd.service
Download the latest release from GitHub.
wget https://github.com/desain-gratis/deployd/releases/latest/download/deployd-linux-amd64.tar.gzsudo mkdir -p /opt/deployd
sudo mkdir -p /etc/deploydExtract the release into the deployment directory.
sudo tar -xzf deployd-linux-amd64.tar.gz -C /opt/deploydThe resulting layout should look like:
/opt/deployd/
└── deployd
Make the executable runnable:
sudo chmod +x /opt/deployd/deploydsudo mkdir -p /etc/deployd
sudo tee /etc/deployd/overwrite.env >/dev/null <<'EOF'
CONFIG=/etc/deployd/config.yaml
SECRET=/etc/deployd/secret.yaml
DEPLOYD_RAFT=/etc/deployd/raft.yaml
EOF
sudo tee /etc/deployd/config.yaml >/dev/null <<'EOF'
host:
name: <hostname>
os: <os, eg. linux>
architecture: <arch, eg. amd64>
# base raft configuration for deployed apps (dragonboat)
raft:
replica_id: <replica id>
base_node_host_dir: <raft host dir /data>
base_wal_dir: <raft host wal dir /data>
http:
public:
address: <bind address eg. :9401>
fqdn: <user accessible URL, eg. https://deployd.com>
ui:
dir: "/var/www"
storage:
s3:
blob:
endpoint: <s3 endpoint>
key_id: <secret>
key_secret: <secret>
use_ssl: false
bucket_name: <s3 bucket>
base_public_url: <public accessible URL of the storage>
clickhouse:
replica:
address: <clickhouse address>
username: <secret>
password: <secret>
database: <secret>
read_timeout: 2s
EOF
They have the same structure as env, and will overwrite the overwrite.env
sudo tee /etc/deployd/secret.yaml >/dev/null <<'EOF'
EOFsudo tee /etc/systemd/system/deployd.service >/dev/null <<'EOF'
[Unit]
Description=Deployd
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/deployd
ExecStart=/opt/deployd/deployd
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
Reload systemd:
sudo systemctl daemon-reloadEnable deployd to start automatically:
sudo systemctl enable deploydStart it:
sudo systemctl start deploydCheck service status:
sudo systemctl status deploydFollow logs:
sudo journalctl -u deployd -f