2015-04-13 04:09:02 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
2015-03-17 18:56:15 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_LOOLWSD_HPP
|
|
|
|
#define INCLUDED_LOOLWSD_HPP
|
|
|
|
|
2015-05-22 08:34:21 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
2015-03-17 18:56:15 -05:00
|
|
|
#include <string>
|
2015-07-13 09:13:06 -05:00
|
|
|
#include <mutex>
|
2015-03-17 18:56:15 -05:00
|
|
|
|
|
|
|
#include <Poco/Util/OptionSet.h>
|
2015-07-13 09:13:06 -05:00
|
|
|
#include <Poco/Random.h>
|
|
|
|
#include <Poco/Path.h>
|
2015-03-17 18:56:15 -05:00
|
|
|
#include <Poco/Util/ServerApplication.h>
|
2015-07-17 13:02:25 -05:00
|
|
|
#include <Poco/SharedMemory.h>
|
2015-07-18 11:35:16 -05:00
|
|
|
#include <Poco/NamedMutex.h>
|
2015-03-17 18:56:15 -05:00
|
|
|
|
|
|
|
class LOOLWSD: public Poco::Util::ServerApplication
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LOOLWSD();
|
|
|
|
~LOOLWSD();
|
|
|
|
|
|
|
|
// An Application is a singleton anyway, so just keep these as
|
|
|
|
// statics
|
|
|
|
static int portNumber;
|
2015-07-24 13:10:24 -05:00
|
|
|
static int timeoutCounter;
|
2015-08-05 19:01:39 -05:00
|
|
|
static bool doTest;
|
2015-11-25 20:49:34 -06:00
|
|
|
static bool volatile isShutDown;
|
2015-06-04 09:07:49 -05:00
|
|
|
static std::string cache;
|
2015-04-08 09:22:42 -05:00
|
|
|
static std::string sysTemplate;
|
|
|
|
static std::string loTemplate;
|
|
|
|
static std::string childRoot;
|
|
|
|
static std::string loSubPath;
|
|
|
|
static std::string jail;
|
2015-07-17 13:02:25 -05:00
|
|
|
static Poco::SharedMemory _sharedForkChild;
|
2015-08-05 17:19:51 -05:00
|
|
|
static Poco::NamedMutex _namedMutexLOOL;
|
2015-10-09 07:55:49 -05:00
|
|
|
static Poco::Random _rng;
|
2015-11-25 21:17:08 -06:00
|
|
|
static Poco::UInt64 _childId;
|
2015-04-08 09:22:42 -05:00
|
|
|
|
2015-05-08 13:24:46 -05:00
|
|
|
static const int DEFAULT_CLIENT_PORT_NUMBER = 9980;
|
|
|
|
static const int MASTER_PORT_NUMBER = 9981;
|
2015-07-24 13:10:24 -05:00
|
|
|
static const int INTERVAL_PROBES = 10;
|
2015-07-24 14:17:46 -05:00
|
|
|
static const int MAINTENANCE_INTERVAL = 1;
|
2015-11-25 20:23:08 -06:00
|
|
|
static const int POLL_TIMEOUT = 1000000;
|
2015-04-20 09:43:31 -05:00
|
|
|
static const std::string CHILD_URI;
|
2015-07-19 15:49:11 -05:00
|
|
|
static const std::string PIDLOG;
|
2015-08-05 19:20:05 -05:00
|
|
|
static const std::string LOKIT_PIDLOG;
|
2015-03-26 01:36:35 -05:00
|
|
|
|
2015-03-17 18:56:15 -05:00
|
|
|
protected:
|
2015-11-25 20:37:08 -06:00
|
|
|
static void setSignals(bool bIgnore);
|
|
|
|
static void handleSignal(int nSignal);
|
|
|
|
|
2015-03-17 18:56:15 -05:00
|
|
|
void initialize(Poco::Util::Application& self) override;
|
|
|
|
void uninitialize() override;
|
|
|
|
void defineOptions(Poco::Util::OptionSet& options) override;
|
|
|
|
void handleOption(const std::string& name, const std::string& value) override;
|
|
|
|
int main(const std::vector<std::string>& args) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void displayHelp();
|
2015-07-13 09:13:06 -05:00
|
|
|
void componentMain();
|
|
|
|
void desktopMain();
|
|
|
|
void startupComponent(int nComponents);
|
|
|
|
void startupDesktop(int nDesktop);
|
|
|
|
int createComponent();
|
|
|
|
int createDesktop();
|
2015-03-17 18:56:15 -05:00
|
|
|
|
2015-04-28 03:02:29 -05:00
|
|
|
static int _numPreSpawnedChildren;
|
2015-07-13 09:13:06 -05:00
|
|
|
static std::mutex _rngMutex;
|
2015-05-22 08:34:21 -05:00
|
|
|
|
|
|
|
#if ENABLE_DEBUG
|
|
|
|
public:
|
|
|
|
static bool runningAsRoot;
|
2015-05-22 11:42:36 -05:00
|
|
|
static int uid;
|
2015-05-22 08:34:21 -05:00
|
|
|
#endif
|
2015-03-17 18:56:15 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|