name: Deployment with Systemctl
sort: 2
Systemctl
Systemctl command is a command used to manage and control services. It allows you to enable, disable, view, start, stop, or restart system services.
Install beego application as a service
Pack your application using
bee packcommand. Copy the resultant.tar.gzfile to target server.Unpack
mkdir -p /usr/local/beepkg && cd "$_"tar -xvzf *.tar.gzrm -rf *.tar.gz
Configure service parameters
cat <<'EOF' > /etc/systemd/system/beepkg.service[Unit]Description=beepkgAssertPathExists=/usr/local/beepkg[Service]WorkingDirectory=/usr/local/beepkgExecStart=/usr/local/beepkg/beepkgExecReload=/bin/kill -HUP $MAINPIDLimitNOFILE=65536Restart=alwaysRestartSec=5[Install]WantedBy=multi-user.targetEOF
Install service
chmod +x beepkgchmod 644 /etc/systemd/system/beepkg.servicesystemctl daemon-reloadsystemctl enable beepkgsystemctl start beepkgsystemctl status beepkg
