]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_object_expirer.cc
update sources to ceph Nautilus 14.2.1
[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
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"
26 #include "rgw_rados.h"
27 #include "rgw_acl.h"
28 #include "rgw_acl_s3.h"
29 #include "rgw_log.h"
30 #include "rgw_formats.h"
31 #include "rgw_usage.h"
32 #include "rgw_object_expirer_core.h"
33
34 #define dout_subsys ceph_subsys_rgw
35
36 static RGWRados *store = NULL;
37
38 class StoreDestructor {
39 RGWRados *store;
40
41 public:
42 explicit StoreDestructor(RGWRados *_s) : store(_s) {}
43 ~StoreDestructor() {
44 if (store) {
45 RGWStoreManager::close_storage(store);
46 }
47 }
48 };
49
50 static void usage()
51 {
52 generic_server_usage();
53 }
54
55 int main(const int argc, const char **argv)
56 {
57 vector<const char *> args;
58 argv_to_vec(argc, argv, args);
59 if (args.empty()) {
60 cerr << argv[0] << ": -h or --help for usage" << std::endl;
61 exit(1);
62 }
63 if (ceph_argparse_need_usage(args)) {
64 usage();
65 exit(0);
66 }
67
68 auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
69 CODE_ENVIRONMENT_DAEMON,
70 CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS, "rgw_data");
71
72 for (std::vector<const char *>::iterator i = args.begin(); i != args.end(); ) {
73 if (ceph_argparse_double_dash(args, i)) {
74 break;
75 }
76 }
77
78 if (g_conf()->daemonize) {
79 global_init_daemonize(g_ceph_context);
80 }
81
82 common_init_finish(g_ceph_context);
83
84 store = RGWStoreManager::get_storage(g_ceph_context, false, false, false, false, false);
85 if (!store) {
86 std::cerr << "couldn't init storage provider" << std::endl;
87 return EIO;
88 }
89
90 rgw_user_init(store);
91 rgw_bucket_init(store->meta_mgr);
92
93 /* Guard to not forget about closing the rados store. */
94 StoreDestructor store_dtor(store);
95
96 RGWObjectExpirer objexp(store);
97 objexp.start_processor();
98
99 const utime_t interval(g_ceph_context->_conf->rgw_objexp_gc_interval, 0);
100 while (true) {
101 interval.sleep();
102 }
103
104 /* unreachable */
105
106 return EXIT_SUCCESS;
107 }