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