seatd: s6-style readiness notification support
This adds the ability to specify the number of an fd that is inherited by the process as open. Once seatd is read to serve requests, it will write a single newline and close the fd.
This commit is contained in:
parent
d03e9d1c35
commit
312d6906ae
2 changed files with 22 additions and 1 deletions
|
@ -13,6 +13,11 @@ seatd - A seat management daemon
|
||||||
*-h*
|
*-h*
|
||||||
Show help message and quit.
|
Show help message and quit.
|
||||||
|
|
||||||
|
*-n*
|
||||||
|
FD to notify readiness on. A single newline will be written and the fd
|
||||||
|
closed when seatd is ready to serve requests. This is compatible with
|
||||||
|
s6's notification protocol.
|
||||||
|
|
||||||
*-u <user>*
|
*-u <user>*
|
||||||
User to own the seatd socket.
|
User to own the seatd socket.
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ int main(int argc, char *argv[]) {
|
||||||
const char *usage = "Usage: seatd [options]\n"
|
const char *usage = "Usage: seatd [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -h Show this help message\n"
|
" -h Show this help message\n"
|
||||||
|
" -n <fd> FD to notify readiness on\n"
|
||||||
" -u <user> User to own the seatd socket\n"
|
" -u <user> User to own the seatd socket\n"
|
||||||
" -g <group> Group to own the seatd socket\n"
|
" -g <group> Group to own the seatd socket\n"
|
||||||
" -s <path> Where to create the seatd socket\n"
|
" -s <path> Where to create the seatd socket\n"
|
||||||
|
@ -78,9 +79,17 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
int uid = 0, gid = 0;
|
int uid = 0, gid = 0;
|
||||||
|
int readiness = -1;
|
||||||
const char *socket_path = getenv("SEATD_SOCK");
|
const char *socket_path = getenv("SEATD_SOCK");
|
||||||
while ((c = getopt(argc, argv, "vhs:g:u:")) != -1) {
|
while ((c = getopt(argc, argv, "vhn:s:g:u:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'n':
|
||||||
|
readiness = atoi(optarg);
|
||||||
|
if (readiness < 0) {
|
||||||
|
fprintf(stderr, "Invalid readiness fd: %s\n", optarg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
socket_path = optarg;
|
socket_path = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -149,6 +158,13 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
log_info("seatd started");
|
log_info("seatd started");
|
||||||
|
|
||||||
|
if (readiness != -1) {
|
||||||
|
if (write(readiness, "\n", 1) == -1) {
|
||||||
|
log_errorf("Could not write readiness signal: %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
close(readiness);
|
||||||
|
}
|
||||||
|
|
||||||
while (server.running) {
|
while (server.running) {
|
||||||
if (poller_poll(&server.poller) == -1) {
|
if (poller_poll(&server.poller) == -1) {
|
||||||
log_errorf("Poller failed: %s", strerror(errno));
|
log_errorf("Poller failed: %s", strerror(errno));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue