2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2010-06-16 05:10:31 +02:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2015-10-04 17:36:19 +02:00
|
|
|
#include "sd-daemon.h"
|
|
|
|
|
2017-07-13 00:01:46 +02:00
|
|
|
#include "parse-util.h"
|
2015-10-04 17:36:19 +02:00
|
|
|
#include "strv.h"
|
2019-03-27 11:32:41 +01:00
|
|
|
#include "time-util.h"
|
2010-06-16 05:10:31 +02:00
|
|
|
|
2018-12-04 09:29:54 +01:00
|
|
|
int main(int argc, char *argv[]) {
|
2015-10-04 17:36:19 +02:00
|
|
|
_cleanup_strv_free_ char **l = NULL;
|
|
|
|
int n, i;
|
2017-07-13 00:01:46 +02:00
|
|
|
usec_t duration = USEC_PER_SEC / 10;
|
|
|
|
|
|
|
|
if (argc >= 2) {
|
|
|
|
unsigned x;
|
|
|
|
|
|
|
|
assert_se(safe_atou(argv[1], &x) >= 0);
|
|
|
|
duration = x * USEC_PER_SEC;
|
|
|
|
}
|
2015-10-04 17:36:19 +02:00
|
|
|
|
|
|
|
n = sd_listen_fds_with_names(false, &l);
|
|
|
|
if (n < 0) {
|
|
|
|
log_error_errno(n, "Failed to get listening fds: %m");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]);
|
2010-06-16 05:10:31 +02:00
|
|
|
|
2014-08-21 17:03:15 +02:00
|
|
|
sd_notify(0,
|
|
|
|
"STATUS=Starting up");
|
2017-07-13 00:01:46 +02:00
|
|
|
usleep(duration);
|
2014-08-21 17:03:15 +02:00
|
|
|
|
|
|
|
sd_notify(0,
|
|
|
|
"STATUS=Running\n"
|
|
|
|
"READY=1");
|
2017-07-13 00:01:46 +02:00
|
|
|
usleep(duration);
|
2014-08-21 17:03:15 +02:00
|
|
|
|
|
|
|
sd_notify(0,
|
|
|
|
"STATUS=Reloading\n"
|
|
|
|
"RELOADING=1");
|
2017-07-13 00:01:46 +02:00
|
|
|
usleep(duration);
|
2014-08-21 17:03:15 +02:00
|
|
|
|
2010-06-16 05:10:31 +02:00
|
|
|
sd_notify(0,
|
|
|
|
"STATUS=Running\n"
|
|
|
|
"READY=1");
|
2017-07-13 00:01:46 +02:00
|
|
|
usleep(duration);
|
2014-08-21 17:03:15 +02:00
|
|
|
|
|
|
|
sd_notify(0,
|
|
|
|
"STATUS=Quitting\n"
|
|
|
|
"STOPPING=1");
|
2017-07-13 00:01:46 +02:00
|
|
|
usleep(duration);
|
2010-06-16 05:10:31 +02:00
|
|
|
|
2015-10-04 17:36:19 +02:00
|
|
|
return EXIT_SUCCESS;
|
2010-06-16 05:10:31 +02:00
|
|
|
}
|