Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write PID file before initializing Globals. #3

Merged
merged 3 commits into from
Sep 24, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
fastcgi-daemon2 (2.10-14) unstable; urgency=low

* Write PID file before initializing globals.

-- Alexander Myltsev <myltsev@yandex-team.ru> Mon, 24 Sep 2012 12:58:53 +0400

fastcgi-daemon2 (2.10-13) unstable; urgency=low

* Added correct stop for daemon with delay (by ekilimchuk@).
Expand Down
6 changes: 3 additions & 3 deletions include/details/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class RequestsThreadPool;

class Globals : private boost::noncopyable {
public:
Globals(Config *config);
Globals(const Config *config);
virtual ~Globals();

Config* config() const;
const Config* config() const;

typedef std::map<std::string, boost::shared_ptr<RequestsThreadPool> > ThreadPoolMap;

Expand All @@ -59,7 +59,7 @@ class Globals : private boost::noncopyable {

private:
ThreadPoolMap pools_;
Config* config_;
const Config* config_;
std::auto_ptr<Loader> loader_;
std::auto_ptr<HandlerSet> handlerSet_;
std::auto_ptr<ComponentSet> componentSet_;
Expand Down
4 changes: 2 additions & 2 deletions library/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace fastcgi
{

Globals::Globals(Config *config) : config_(config), loader_(new Loader()),
Globals::Globals(const Config *config) : config_(config), loader_(new Loader()),
handlerSet_(new HandlerSet()), componentSet_(new ComponentSet()), logger_(NULL)
{
loader_->init(config);
Expand Down Expand Up @@ -58,7 +58,7 @@ Globals::logger() const {
return logger_;
}

Config*
const Config*
Globals::config() const {
return config_;
}
Expand Down
5 changes: 2 additions & 3 deletions main/fcgi_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ FCGIServer::start() {

status_ = LOADING;

pid(globals_->config()->asString("/fastcgi/daemon/pidfile"));

logTimes_ = globals_->config()->asInt("/fastcgi/daemon/log-times", 0);

initMonitorThread();
Expand Down Expand Up @@ -372,7 +370,8 @@ FCGIServer::monitor() {
}

void
FCGIServer::pid(const std::string &file) {
FCGIServer::writePid(const Config& config) {
const std::string& file = config.asString("/fastcgi/daemon/pidfile");
try {
std::ofstream f(file.c_str());
f.exceptions(std::ios::badbit);
Expand Down
4 changes: 2 additions & 2 deletions main/fcgi_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class FCGIServer : public Server {
public:
FCGIServer(boost::shared_ptr<Globals> globals);
virtual ~FCGIServer();

static void writePid(const Config& config);
void start();
void stop();
void join();
Expand All @@ -84,8 +86,6 @@ class FCGIServer : public Server {

std::string getServerInfo() const;

void pid(const std::string &file);

void initMonitorThread();
void initRequestCache();
void initTimeStatistics();
Expand Down
3 changes: 2 additions & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ main(int argc, char *argv[]) {
}
}

std::auto_ptr<Config> config = Config::create(argc, argv);
boost::scoped_ptr<Config> config(Config::create(argc, argv));
FCGIServer::writePid(*config);
boost::shared_ptr<Globals> globals(new Globals(config.get()));
FCGIServer server(globals);
::server = &server;
Expand Down