]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
8c47c732 LP |
2 | |
3 | #include <unistd.h> | |
4 | ||
8dd4c05b LP |
5 | #include "sd-daemon.h" |
6 | ||
f06dcdca | 7 | #include "parse-util.h" |
8dd4c05b | 8 | #include "strv.h" |
8c47c732 | 9 | |
f2a3de01 | 10 | int main(int argc, char *argv[]) { |
8dd4c05b LP |
11 | _cleanup_strv_free_ char **l = NULL; |
12 | int n, i; | |
f06dcdca ZJS |
13 | usec_t duration = USEC_PER_SEC / 10; |
14 | ||
15 | if (argc >= 2) { | |
16 | unsigned x; | |
17 | ||
18 | assert_se(safe_atou(argv[1], &x) >= 0); | |
19 | duration = x * USEC_PER_SEC; | |
20 | } | |
8dd4c05b LP |
21 | |
22 | n = sd_listen_fds_with_names(false, &l); | |
23 | if (n < 0) { | |
24 | log_error_errno(n, "Failed to get listening fds: %m"); | |
25 | return EXIT_FAILURE; | |
26 | } | |
27 | ||
28 | for (i = 0; i < n; i++) | |
29 | log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]); | |
8c47c732 | 30 | |
308d72dc LP |
31 | sd_notify(0, |
32 | "STATUS=Starting up"); | |
f06dcdca | 33 | usleep(duration); |
308d72dc LP |
34 | |
35 | sd_notify(0, | |
36 | "STATUS=Running\n" | |
37 | "READY=1"); | |
f06dcdca | 38 | usleep(duration); |
308d72dc LP |
39 | |
40 | sd_notify(0, | |
41 | "STATUS=Reloading\n" | |
42 | "RELOADING=1"); | |
f06dcdca | 43 | usleep(duration); |
308d72dc | 44 | |
8c47c732 LP |
45 | sd_notify(0, |
46 | "STATUS=Running\n" | |
47 | "READY=1"); | |
f06dcdca | 48 | usleep(duration); |
308d72dc LP |
49 | |
50 | sd_notify(0, | |
51 | "STATUS=Quitting\n" | |
52 | "STOPPING=1"); | |
f06dcdca | 53 | usleep(duration); |
8c47c732 | 54 | |
8dd4c05b | 55 | return EXIT_SUCCESS; |
8c47c732 | 56 | } |