cluck 1.0.1
The cluster lock service.
main.cpp
Go to the documentation of this file.
1// Copyright (c) 2016-2025 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/cluck
4// contact@m2osw.com
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19
20// self
21//
22#include "cluckd.h"
23
24
25// cluck
26//
27#include <cluck/exception.h>
28
29
30// snaplogger
31//
32#include <snaplogger/message.h>
33
34
35// eventdispatcher
36//
37#include <eventdispatcher/signal_handler.h>
38
39
40// libexcept
41//
42#include <libexcept/file_inheritance.h>
43
44
45// advgetopt
46//
47#include <advgetopt/exception.h>
48
49
50// last include
51//
52#include <snapdev/poison.h>
53
54
55
56int main(int argc, char * argv[])
57{
58 ed::signal_handler::create_instance();
59 libexcept::verify_inherited_files();
60 libexcept::collect_stack_trace();
61
62 std::string errmsg;
63 try
64 {
65 cluck_daemon::cluckd::pointer_t lock(std::make_shared<cluck_daemon::cluckd>(argc, argv));
66 lock->add_connections();
67 lock->run();
68 return 0;
69 }
70 catch(advgetopt::getopt_exit const & e)
71 {
72 return e.code();
73 }
74 catch(std::exception const & e)
75 {
76 errmsg = "cluckd: std::exception caught! ";
77 errmsg += e.what();
78 }
79 catch(...)
80 {
81 errmsg = "cluckd: unknown exception caught!";
82 }
83
84 SNAP_LOG_FATAL << errmsg << SNAP_LOG_SEND;
85 if(isatty(STDERR_FILENO))
86 {
87 std::cerr << errmsg << std::endl;
88 }
89
90 return 1;
91}
92
93
94
95// vim: ts=4 sw=4 et
std::shared_ptr< cluckd > pointer_t
Definition cluckd.h:50
Daemon handling inter-computer locking.
int main(int argc, char *argv[])
Definition main.cpp:56

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.