File tree Expand file tree Collapse file tree 8 files changed +74
-0
lines changed Expand file tree Collapse file tree 8 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ service:
44
44
enabled : true
45
45
running : true
46
46
47
+ lifecycled :
48
+ enabled : true
49
+ running : true
50
+
47
51
sshd :
48
52
enabled : true
49
53
running : true
@@ -89,6 +93,9 @@ process:
89
93
buildkite-agent :
90
94
running : true
91
95
96
+ lifecycled :
97
+ running : true
98
+
92
99
sshd :
93
100
running : true
94
101
Original file line number Diff line number Diff line change 45
45
"type" : " shell" ,
46
46
"script" : " scripts/install-cloudwatch-agent.sh"
47
47
},
48
+ {
49
+ "type" : " shell" ,
50
+ "script" : " scripts/install-lifecycled.sh"
51
+ },
48
52
{
49
53
"type" : " shell" ,
50
54
"script" : " scripts/install-docker.sh"
Original file line number Diff line number Diff line change @@ -197,6 +197,15 @@ if [[ -n "${BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT}" ]] ; then
197
197
rm /tmp/elastic_bootstrap
198
198
fi
199
199
200
+ cat << EOF > /etc/lifecycled
201
+ AWS_REGION=${AWS_REGION}
202
+ LIFECYCLED_HANDLER=/usr/local/bin/stop-agent-gracefully
203
+ LIFECYCLED_CLOUDWATCH_GROUP=/buildkite/lifecycled
204
+ EOF
205
+
206
+ systemctl enable lifecycled.service
207
+ systemctl start lifecycled
208
+
200
209
# wait for docker to start
201
210
next_wait_time=0
202
211
until docker ps || [ $next_wait_time -eq 5 ]; do
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -eu -o pipefail
3
+
4
+ LIFECYCLED_VERSION=v3.2.0
5
+
6
+ MACHINE=$( uname -m)
7
+
8
+ case " ${MACHINE} " in
9
+ x86_64) ARCH=amd64;;
10
+ aarch64) ARCH=arm64;;
11
+ * ) ARCH=unknown;;
12
+ esac
13
+
14
+ echo " Installing lifecycled ${LIFECYCLED_VERSION} ..."
15
+
16
+ sudo touch /etc/lifecycled
17
+ sudo curl -Lf -o /usr/bin/lifecycled \
18
+ https://github.com/buildkite/lifecycled/releases/download/${LIFECYCLED_VERSION} /lifecycled-linux-${ARCH}
19
+ sudo chmod +x /usr/bin/lifecycled
20
+ sudo curl -Lf -o /etc/systemd/system/lifecycled.service \
21
+ https://raw.githubusercontent.com/buildkite/lifecycled/${LIFECYCLED_VERSION} /init/systemd/lifecycled.unit
22
+
Original file line number Diff line number Diff line change 44
44
"type" : " powershell" ,
45
45
"script" : " scripts/install-cloudwatch-agent.ps1"
46
46
},
47
+ {
48
+ "type" : " powershell" ,
49
+ "script" : " scripts/install-lifecycled.ps1"
50
+ },
47
51
{
48
52
"type" : " powershell" ,
49
53
"script" : " scripts/install-docker.ps1"
Original file line number Diff line number Diff line change @@ -140,6 +140,10 @@ disconnect-after-job=${Env:BUILDKITE_TERMINATE_INSTANCE_AFTER_JOB}
140
140
"@
141
141
$OFS = " "
142
142
143
+ nssm set lifecycled AppEnvironmentExtra :AWS_REGION= $Env: AWS_REGION
144
+ nssm set lifecycled AppEnvironmentExtra + LIFECYCLED_HANDLER= " C:\buildkite-agent\bin\stop-agent-gracefully.ps1"
145
+ Restart-Service lifecycled
146
+
143
147
# wait for docker to start
144
148
$next_wait_time = 0
145
149
do {
Original file line number Diff line number Diff line change 22
22
"file_path" : " C:\\ buildkite-agent\\ buildkite-agent.log" ,
23
23
"log_group_name" : " /buildkite/buildkite-agent" ,
24
24
"timestamp_format" : " %Y-%m-%dT%H:%M:%S.%f"
25
+ },
26
+ {
27
+ "file_path" : " C:\\ lifecycled\\ lifecycled.log" ,
28
+ "log_group_name" : " /buildkite/lifecycled" ,
29
+ "timestamp_format" : " %Y-%m-%dT%H:%M:%S.%f"
25
30
}
26
31
]
27
32
},
Original file line number Diff line number Diff line change
1
+ # Stop script execution when a non-terminating error occurs
2
+ $ErrorActionPreference = " Stop"
3
+
4
+ $lifecycled_version = " v3.2.0"
5
+
6
+ Write-Output " Installing lifecycled ${lifecycled_version} ..."
7
+
8
+ New-Item - ItemType directory - Path C:\lifecycled\bin
9
+
10
+ [Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12
11
+ Invoke-WebRequest - OutFile C:\lifecycled\bin\lifecycled.exe https:// github.com / buildkite/ lifecycled/ releases/ download/ ${lifecycled_version} / lifecycled-windows-amd64.exe
12
+
13
+ Write-Output " Configure lifecycled to run on startup..."
14
+ nssm install lifecycled C:\lifecycled\bin\lifecycled.exe
15
+ If ($lastexitcode -ne 0 ) { Exit $lastexitcode }
16
+ nssm set lifecycled AppStdout C:\lifecycled\lifecycled.log
17
+ If ($lastexitcode -ne 0 ) { Exit $lastexitcode }
18
+ nssm set lifecycled AppStderr C:\lifecycled\lifecycled.log
19
+ If ($lastexitcode -ne 0 ) { Exit $lastexitcode }
You can’t perform that action at this time.
0 commit comments