@@ -655,6 +655,8 @@ spinner() { #{{{
655655
656656clean_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
@@ -1633,6 +1638,45 @@ EOF
16331638 fi
16341639}
16351640
1641+ configure_golang_service (){
1642+ debug " Configuring golang service"
1643+ mkdir -p /var/log/sgrunner/
1644+ mkdir -p /etc/sgrunner
1645+ cat > /etc/sgrunner/config.yaml << EOF
1646+ sg_org: ${ORGANIZATION_NAME}
1647+ sg_runner_group: ${RUNNER_GROUP_ID}
1648+ sg_runner_group_token: ${SG_NODE_TOKEN}
1649+ integration_id: ${AZURE_STORAGE_AUTH_INTEGRATION_ID}
1650+ log_level: info
1651+ EOF
1652+
1653+ cat > /etc/systemd/system/sgrunner.service << EOF
1654+ [Unit]
1655+ Description=My Go Application
1656+ After=network.target
1657+
1658+ [Service]
1659+ Type=simple
1660+ ExecStart=/opt/sgrunner/sgrunner
1661+ WorkingDirectory=/opt/sgrunner
1662+ Restart=on-failure
1663+ RestartSec=5s
1664+
1665+ # Logging
1666+ StandardOutput=journal
1667+ StandardError=journal
1668+
1669+ [Install]
1670+ WantedBy=multi-user.target
1671+ EOF
1672+
1673+ systemctl daemon-reload
1674+ systemctl start sgrunner
1675+ if [[ $? != 0 ]]; then
1676+ err " failed to start the sgrunner service"
1677+ fi
1678+ }
1679+
16361680main () { #{{{
16371681
16381682 [[ " ${* } " =~ --help || $# -lt 1 ]] && show_help && exit 0
@@ -1714,6 +1758,7 @@ main() { #{{{
17141758 parse_arguments " $@ "
17151759 check_sg_args
17161760 configure_http_proxy
1761+ # configure_golang_service
17171762 register_instance
17181763 ;;
17191764 deregister)
0 commit comments