Project
Loading...
Searching...
No Matches
CleanCCDBSemaphores.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "CCDB/CcdbApi.h"
13#include <iostream>
14#include <boost/program_options.hpp>
15
16namespace bpo = boost::program_options;
17
18bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv[], bpo::variables_map& vm)
19{
20 options.add_options()(
21 "cachepath,p", bpo::value<std::string>()->default_value("ccdb"), "path to whole CCDB cache dir as a basis for semaphore search")(
22 "sema,s", bpo::value<std::string>()->default_value(""), "Specific named semaphore to be remove")(
23 "help,h", "Produce help message.");
24
25 try {
26 bpo::store(parse_command_line(argc, argv, options), vm);
27 // help
28 if (vm.count("help")) {
29 std::cout << options << std::endl;
30 return false;
31 }
32 bpo::notify(vm);
33 } catch (const bpo::error& e) {
34 std::cerr << e.what() << "\n\n";
35 std::cerr << "Error parsing command line arguments; Available options:\n";
36
37 std::cerr << options << std::endl;
38 return false;
39 }
40 return true;
41}
42
43// A simple tool to clean CCDB related semaphores
44int main(int argc, char* argv[])
45{
46 bpo::options_description options("Tool to find and remove leaking CCDB semaphore from the system");
47 bpo::variables_map vm;
48 if (!initOptionsAndParse(options, argc, argv, vm)) {
49 return 1;
50 }
51
52 std::string sema = vm["sema"].as<std::string>();
53 if (sema.size() > 0) {
54 if (o2::ccdb::CcdbApi::removeSemaphore(sema, true)) {
55 std::cout << "Successfully removed " << sema << "\n";
56 }
57 }
58
59 std::string path = vm["cachepath"].as<std::string>();
61 return 0;
62}
bool initOptionsAndParse(bpo::options_description &options, int argc, char *argv[], bpo::variables_map &vm)
static void removeLeakingSemaphores(std::string const &basedir, bool remove=false)
Definition CcdbApi.cxx:1790
static bool removeSemaphore(std::string const &name, bool remove=false)
Definition CcdbApi.cxx:1767
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
#define main