Skip to content

Commit 2d3a323

Browse files
author
root
committed
changes for sgrunner runner service
1 parent 2921672 commit 2d3a323

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

main.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ spinner() { #{{{
655655

656656
clean_local_setup() { #{{{
657657
debug "Stopping services.."
658+
systemctl stop sgrunner 2>/dev/null
659+
debug "Stopping sgrunner.."
658660
systemctl stop ecs 2>/dev/null
659661
debug "Stopping $CONTAINER_ORCHESTRATOR containers.."
660662
$CONTAINER_ORCHESTRATOR stop ecs-agent fluentbit-agent >&/dev/null
@@ -679,6 +681,9 @@ clean_local_setup() { #{{{
679681
"/etc/systemd/system/ecs.service.d/http-proxy.conf"
680682
"/etc/systemd/system/amazon-ssm-agent.service.d/http-proxy.conf"
681683
"/etc/systemd/system/snap.amazon-ssm-agent.amazon-ssm-agent.service.d/http-proxy.conf"
684+
"/var/log/sgrunner"
685+
"/etc/systemd/system/sgrunner.service"
686+
"/opt/sgrunner"
682687
)
683688

684689
# Loop through the array and remove each item
@@ -1235,6 +1240,7 @@ register_instance() { #{{{
12351240

12361241
fetch_organization_info
12371242
configure_local_data
1243+
configure_golang_service
12381244
configure_fluentbit
12391245
configure_local_network
12401246

@@ -1633,6 +1639,54 @@ EOF
16331639
fi
16341640
}
16351641

1642+
configure_golang_service(){
1643+
info "Configuring golang service"
1644+
1645+
mkdir -p /opt/sgrunner/
1646+
cp sgrunner /opt/sgrunner/sgrunner
1647+
1648+
mkdir -p /var/log/sgrunner/
1649+
mkdir -p /etc/sgrunner
1650+
debug "writing sgrunner config"
1651+
cat > /etc/sgrunner/config.yaml << EOF
1652+
sg_org: ${ORGANIZATION_NAME}
1653+
sg_runner_group: ${RUNNER_GROUP_ID}
1654+
sg_runner_group_token: ${SG_NODE_TOKEN}
1655+
integration_id: ${AZURE_STORAGE_AUTH_INTEGRATION_ID}
1656+
log_level: info
1657+
EOF
1658+
debug "generated configuration for golang service"
1659+
1660+
debug "writing sgrunner systemd file"
1661+
cat > /etc/systemd/system/sgrunner.service << EOF
1662+
[Unit]
1663+
Description=My Go Application
1664+
After=network.target
1665+
1666+
[Service]
1667+
Type=simple
1668+
ExecStart=/opt/sgrunner/sgrunner
1669+
WorkingDirectory=/opt/sgrunner
1670+
Restart=on-failure
1671+
RestartSec=5s
1672+
1673+
# Logging
1674+
StandardOutput=journal
1675+
StandardError=journal
1676+
1677+
[Install]
1678+
WantedBy=multi-user.target
1679+
EOF
1680+
debug "generated systemd file for sgrunner service"
1681+
1682+
systemctl daemon-reload
1683+
systemctl start sgrunner
1684+
if [[ $? != 0 ]]; then
1685+
err "failed to start the sgrunner service"
1686+
exit 1
1687+
fi
1688+
}
1689+
16361690
main() { #{{{
16371691

16381692
[[ "${*}" =~ --help || $# -lt 1 ]] && show_help && exit 0

0 commit comments

Comments
 (0)