reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
MOHParkServer.cxx
Go to the documentation of this file.
1#include <signal.h>
2
4
5#include "AppSubsystem.hxx"
6#include "Server.hxx"
7
8#include <rutil/Log.hxx>
9#include <rutil/Logger.hxx>
10#include <rutil/DnsUtil.hxx>
14
15using namespace mohparkserver;
16using namespace recon;
17using namespace resip;
18using namespace std;
19
20#define RESIPROCATE_SUBSYSTEM AppSubsystem::MOHPARKSERVER
21
22static bool finished = false;
23
24static void
25signalHandler(int signo)
26{
27 std::cerr << "Shutting down..." << endl;
28 finished = true;
29}
30
31int
32main (int argc, char** argv)
33{
34#ifndef _WIN32
35 if ( signal( SIGPIPE, SIG_IGN) == SIG_ERR)
36 {
37 cerr << "Couldn't install signal handler for SIGPIPE" << endl;
38 exit(-1);
39 }
40#else
41#if defined(_DEBUG) && defined(LEAK_CHECK)
42 resip::FindMemoryLeaks fml;
43#endif
44#endif
45
46 if ( signal( SIGINT, signalHandler ) == SIG_ERR )
47 {
48 cerr << "Couldn't install signal handler for SIGINT" << endl;
49 exit( -1 );
50 }
51
52 if ( signal( SIGTERM, signalHandler ) == SIG_ERR )
53 {
54 cerr << "Couldn't install signal handler for SIGTERM" << endl;
55 exit( -1 );
56 }
57
59
61 // Create Server
63 {
64 ConfigParser config(argc, argv);
65 Server server(config);
66
68 // Startup and run...
70
71 server.startup();
72
73 while(true)
74 {
75 server.process(500);
76 if(finished) break;
77 }
78
79 server.shutdown();
80 }
81
82 InfoLog(<< "MOHParkServer is shutdown.");
83 sleepSeconds(2);
84}
85
86/* ====================================================================
87
88 Copyright (c) 2010, SIP Spectrum, Inc.
89 All rights reserved.
90
91 Redistribution and use in source and binary forms, with or without
92 modification, are permitted provided that the following conditions are
93 met:
94
95 1. Redistributions of source code must retain the above copyright
96 notice, this list of conditions and the following disclaimer.
97
98 2. Redistributions in binary form must reproduce the above copyright
99 notice, this list of conditions and the following disclaimer in the
100 documentation and/or other materials provided with the distribution.
101
102 3. Neither the name of SIP Spectrum nor the names of its contributors
103 may be used to endorse or promote products derived from this
104 software without specific prior written permission.
105
106 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
107 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
108 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
109 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
110 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
111 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
112 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
113 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
114 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
116 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117
118 ==================================================================== */
119
#define InfoLog(args_)
Definition Logger.hxx:131
int main(int argc, char **argv)
static void signalHandler(int signo)
static bool finished
void startup()
Starts the recon thread(s).
Definition Server.cxx:398
void shutdown()
Used to initiate a shutdown of the server.
Definition Server.cxx:432
void process(int timeoutMs)
This should be called in a loop to give process cycles to the server.
Definition Server.cxx:425
dcm! – add UnusedChecking(_enum) below;
void sleepSeconds(unsigned int seconds)
Definition Time.cxx:28
void initNetwork()
set up network - does nothing in unix but needed for windows
Definition Socket.cxx:83