Created
August 28, 2015 16:04
-
-
Save emaxerrno/f0fcd9d1c1a9a8c58ed7 to your computer and use it in GitHub Desktop.
enable_dumps.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <glog/logging.h> | |
| #include <mesos/executor.hpp> | |
| #include <sstream> | |
| #include <sys/resource.h> // core dumps | |
| #include "gen-cpp/bolt_types.h" | |
| #include "bolt/mesos/BoltMesosExecutor.hpp" | |
| void enableCoreDump() { | |
| // Try to enable core dumps | |
| struct rlimit core_limit; | |
| core_limit.rlim_cur = RLIM_INFINITY; | |
| core_limit.rlim_max = RLIM_INFINITY; | |
| PCHECK(::setrlimit(RLIMIT_CORE, &core_limit) >= 0) | |
| << "Setting the core dumps was anot allowed"; | |
| } | |
| void enableMaxOpenFiles() { | |
| struct rlimit file_limit; | |
| file_limit.rlim_cur = RLIM_INFINITY; | |
| file_limit.rlim_max = RLIM_INFINITY; | |
| // First get the limit on open files | |
| ::getrlimit (RLIMIT_NOFILE, &file_limit); | |
| file_limit.rlim_cur = file_limit.rlim_max; | |
| PCHECK(::setrlimit(RLIMIT_NOFILE, &file_limit) >= 0) | |
| << "Setting the core dumps was anot allowed"; | |
| } | |
| int main(int argc, char *argv[]) { | |
| // Slaves initialize google log | |
| // bolt::logging::glog_init(argv[0]); | |
| using namespace ::bolt; | |
| using namespace ::mesos; | |
| std::stringstream ss; | |
| for(auto i = 0; i < argc; ++i) { | |
| ss << " " << argv[i]; | |
| } | |
| LOG(INFO) << "Starting: " << ss.str(); | |
| enableCoreDump(); | |
| enableMaxOpenFiles(); | |
| BoltMesosExecutor executor; | |
| MesosExecutorDriver driver(&executor); | |
| return driver.run() == DRIVER_STOPPED ? 0 : 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment