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