Skip to content

Commit 5c64f61

Browse files
authored
Merge pull request #922 from buildkite/revert-908-keithduncan/remove-lifecycled
Revert "Remove lifecycled"
2 parents f8ce90f + 0388a19 commit 5c64f61

File tree

8 files changed

+74
-0
lines changed

8 files changed

+74
-0
lines changed

goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ service:
4444
enabled: true
4545
running: true
4646

47+
lifecycled:
48+
enabled: true
49+
running: true
50+
4751
sshd:
4852
enabled: true
4953
running: true
@@ -89,6 +93,9 @@ process:
8993
buildkite-agent:
9094
running: true
9195

96+
lifecycled:
97+
running: true
98+
9299
sshd:
93100
running: true
94101

packer/linux/buildkite-ami.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
"type": "shell",
4646
"script": "scripts/install-cloudwatch-agent.sh"
4747
},
48+
{
49+
"type": "shell",
50+
"script": "scripts/install-lifecycled.sh"
51+
},
4852
{
4953
"type": "shell",
5054
"script": "scripts/install-docker.sh"

packer/linux/conf/bin/bk-install-elastic-stack.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ if [[ -n "${BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT}" ]] ; then
197197
rm /tmp/elastic_bootstrap
198198
fi
199199

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+
200209
# wait for docker to start
201210
next_wait_time=0
202211
until docker ps || [ $next_wait_time -eq 5 ]; do
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+

packer/windows/buildkite-ami.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"type": "powershell",
4545
"script": "scripts/install-cloudwatch-agent.ps1"
4646
},
47+
{
48+
"type": "powershell",
49+
"script": "scripts/install-lifecycled.ps1"
50+
},
4751
{
4852
"type": "powershell",
4953
"script": "scripts/install-docker.ps1"

packer/windows/conf/bin/bk-install-elastic-stack.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ disconnect-after-job=${Env:BUILDKITE_TERMINATE_INSTANCE_AFTER_JOB}
140140
"@
141141
$OFS=" "
142142

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+
143147
# wait for docker to start
144148
$next_wait_time=0
145149
do {

packer/windows/conf/cloudwatch-agent/amazon-cloudwatch-agent.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"file_path": "C:\\buildkite-agent\\buildkite-agent.log",
2323
"log_group_name": "/buildkite/buildkite-agent",
2424
"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"
2530
}
2631
]
2732
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 }

0 commit comments

Comments
 (0)