Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P91435
(An Untitled Masterwork)
Active
Public
Actions
Authored by
fgiunchedi
on Apr 24 2026, 11:11 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F77683271: raw-paste-data.txt
Apr 24 2026, 11:11 AM
2026-04-24 11:11:12 (UTC+0)
Subscribers
None
#!/bin/bash
# Restart all webservice tools started before --cutoff-timestamp
set
-euo pipefail
PREFIX
=
"
$(
cat /etc/wmcs-project
)
"
CUTOFF_TIMESTAMP
=
""
webservice_tools
()
{
for
file in /data/project/*/service.manifest
;
do
tool
=
"
$(
echo
$file
|
cut -d/ -f4
)
"
if
! grep -q
"backend:"
"
$file
"
;
then
echo
"
$tool
no backend set"
>
&
2
continue
fi
if
test
-f
"/data/project/
$tool
/k8s.disabled"
;
then
echo
"
$tool
disabled"
>
&
2
continue
fi
echo
$tool
done
}
restart_webservice_tools
()
{
local
cutoff_timestamp
=
"
$1
"
local
prefix
=
"
$2
"
for
tool in
$(
webservice_tools
)
;
do
container_start_timestamps
=
$(
kubectl get pods -n
"tool-
$tool
"
\
--field-selector
=
status.phase
=
Running
\
-o
jsonpath
=
'{range .items[*]}{.status.containerStatuses[0].state.running.startedAt}{"\n"}{end}'
|
xargs -I
{}
-- date -d
{}
+%s
)
if
[
-z
"
$container_start_timestamps
"
]
;
then
echo
"No running pods found for
$tool
"
>
&
2
continue
fi
min_start_timestamp
=
$(
echo
"
$container_start_timestamps
"
|
sort --numeric-sort
|
head -1
)
# Skip tools restarted after cutoff_timestamp
if
[
"
$min_start_timestamp
"
-ge
"
$cutoff_timestamp
"
]
;
then
continue
fi
echo
"Restarting
$prefix
.
$tool
"
sudo -iu
"
$prefix
.
$tool
"
toolforge webservice restart
||
true
sleep
6
done
}
OPTS
=
$(
getopt -o
''
--long cutoff-timestamp: -n
"
$0
"
--
"
$@
"
)
if
[
$?
-ne
0
]
;
then
echo
"Usage:
$0
[--cutoff-timestamp <unix_timestamp>]"
>
&
2
exit
1
fi
eval
set
--
"
$OPTS
"
while
true
;
do
case
"
$1
"
in
--cutoff-timestamp
)
CUTOFF_TIMESTAMP
=
"
$2
"
shift
2
;;
--
)
shift
break
;;
*
)
echo
"Unexpected option:
$1
"
>
&
2
exit
1
;;
esac
done
restart_webservice_tools
$CUTOFF_TIMESTAMP
$PREFIX
Event Timeline
fgiunchedi
created this paste.
Apr 24 2026, 11:11 AM
2026-04-24 11:11:12 (UTC+0)
fgiunchedi
mentioned this in
T420565: Audit tools memory requests vs actual usage
.
Log In to Comment