]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
7c673cae FG |
3 | |
4 | #include <errno.h> | |
5 | #include <iostream> | |
6 | #include <sstream> | |
7 | #include <string> | |
8 | ||
7c673cae FG |
9 | |
10 | #include "auth/Crypto.h" | |
11 | ||
12 | #include "common/armor.h" | |
13 | #include "common/ceph_json.h" | |
14 | #include "common/config.h" | |
15 | #include "common/ceph_argparse.h" | |
16 | #include "common/Formatter.h" | |
17 | #include "common/errno.h" | |
18 | ||
19 | #include "global/global_init.h" | |
20 | ||
21 | #include "include/utime.h" | |
22 | #include "include/str_list.h" | |
23 | ||
24 | #include "rgw_user.h" | |
25 | #include "rgw_bucket.h" | |
7c673cae FG |
26 | #include "rgw_acl.h" |
27 | #include "rgw_acl_s3.h" | |
28 | #include "rgw_log.h" | |
29 | #include "rgw_formats.h" | |
30 | #include "rgw_usage.h" | |
7c673cae FG |
31 | #include "rgw_object_expirer_core.h" |
32 | ||
33 | #define dout_subsys ceph_subsys_rgw | |
34 | ||
20effc67 | 35 | static rgw::sal::Store* store = NULL; |
7c673cae FG |
36 | |
37 | class StoreDestructor { | |
20effc67 | 38 | rgw::sal::Store* store; |
7c673cae FG |
39 | |
40 | public: | |
20effc67 | 41 | explicit StoreDestructor(rgw::sal::Store* _s) : store(_s) {} |
7c673cae FG |
42 | ~StoreDestructor() { |
43 | if (store) { | |
20effc67 | 44 | StoreManager::close_storage(store); |
7c673cae FG |
45 | } |
46 | } | |
47 | }; | |
48 | ||
49 | static void usage() | |
50 | { | |
51 | generic_server_usage(); | |
52 | } | |
53 | ||
54 | int main(const int argc, const char **argv) | |
55 | { | |
20effc67 | 56 | auto args = argv_to_vec(argc, argv); |
11fdf7f2 TL |
57 | if (args.empty()) { |
58 | cerr << argv[0] << ": -h or --help for usage" << std::endl; | |
59 | exit(1); | |
60 | } | |
61 | if (ceph_argparse_need_usage(args)) { | |
62 | usage(); | |
63 | exit(0); | |
64 | } | |
7c673cae FG |
65 | |
66 | auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, | |
67 | CODE_ENVIRONMENT_DAEMON, | |
f67539c2 | 68 | CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); |
7c673cae FG |
69 | |
70 | for (std::vector<const char *>::iterator i = args.begin(); i != args.end(); ) { | |
71 | if (ceph_argparse_double_dash(args, i)) { | |
72 | break; | |
7c673cae FG |
73 | } |
74 | } | |
75 | ||
11fdf7f2 | 76 | if (g_conf()->daemonize) { |
7c673cae FG |
77 | global_init_daemonize(g_ceph_context); |
78 | } | |
79 | ||
80 | common_init_finish(g_ceph_context); | |
81 | ||
b3b6e05e | 82 | const DoutPrefix dp(cct.get(), dout_subsys, "rgw object expirer: "); |
20effc67 | 83 | store = StoreManager::get_storage(&dp, g_ceph_context, "rados", false, false, false, false, false); |
7c673cae FG |
84 | if (!store) { |
85 | std::cerr << "couldn't init storage provider" << std::endl; | |
86 | return EIO; | |
87 | } | |
88 | ||
7c673cae FG |
89 | /* Guard to not forget about closing the rados store. */ |
90 | StoreDestructor store_dtor(store); | |
91 | ||
92 | RGWObjectExpirer objexp(store); | |
93 | objexp.start_processor(); | |
94 | ||
95 | const utime_t interval(g_ceph_context->_conf->rgw_objexp_gc_interval, 0); | |
96 | while (true) { | |
97 | interval.sleep(); | |
98 | } | |
99 | ||
100 | /* unreachable */ | |
101 | ||
102 | return EXIT_SUCCESS; | |
103 | } |