Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Write PID file before initializing globals.

Initializing globals can take a long time
(e.g. if the server has to index a large dataset
before serving requests), and it can be useful
to be able to kill the server during that time.
  • Loading branch information...
commit 43d72c9af752521969e3e4d7fd3e6a9669750cb5 1 parent 1a88d41
Alexander Myltsev avm authored
5 main/fcgi_server.cpp
@@ -88,8 +88,6 @@ FCGIServer::start() {
88 88
89 89 status_ = LOADING;
90 90
91   - pid(globals_->config()->asString("/fastcgi/daemon/pidfile"));
92   -
93 91 logTimes_ = globals_->config()->asInt("/fastcgi/daemon/log-times", 0);
94 92
95 93 initMonitorThread();
@@ -372,7 +370,8 @@ FCGIServer::monitor() {
372 370 }
373 371
374 372 void
375   -FCGIServer::pid(const std::string &file) {
  373 +FCGIServer::writePid(const Config& config) {
  374 + const std::string& file = config.asString("/fastcgi/daemon/pidfile");
376 375 try {
377 376 std::ofstream f(file.c_str());
378 377 f.exceptions(std::ios::badbit);
4 main/fcgi_server.h
@@ -71,6 +71,8 @@ class FCGIServer : public Server {
71 71 public:
72 72 FCGIServer(boost::shared_ptr<Globals> globals);
73 73 virtual ~FCGIServer();
  74 +
  75 + static void writePid(const Config& config);
74 76 void start();
75 77 void stop();
76 78 void join();
@@ -84,8 +86,6 @@ class FCGIServer : public Server {
84 86
85 87 std::string getServerInfo() const;
86 88
87   - void pid(const std::string &file);
88   -
89 89 void initMonitorThread();
90 90 void initRequestCache();
91 91 void initTimeStatistics();
3  main/main.cpp
@@ -102,7 +102,8 @@ main(int argc, char *argv[]) {
102 102 }
103 103 }
104 104
105   - std::auto_ptr<Config> config = Config::create(argc, argv);
  105 + boost::scoped_ptr<Config> config(Config::create(argc, argv));
  106 + FCGIServer::writePid(*config);
106 107 boost::shared_ptr<Globals> globals(new Globals(config.get()));
107 108 FCGIServer server(globals);
108 109 ::server = &server;

0 comments on commit 43d72c9

Please sign in to comment.
Something went wrong with that request. Please try again.