mirror of https://gitee.com/bigwinds/arangodb
added some error messages when using --pid-file
This commit is contained in:
parent
ad456ded93
commit
5cbc0ad3c7
|
@ -357,6 +357,17 @@ namespace triagens {
|
|||
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
|
||||
off_t size (string const& path) {
|
||||
struct stat stbuf;
|
||||
int res = stat(path.c_str(), &stbuf);
|
||||
if (res != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return stbuf.st_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -130,6 +130,14 @@ namespace triagens {
|
|||
|
||||
bool exists (string const& path);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the size of a file. will return 0 for non-existing files
|
||||
///
|
||||
/// the caller should check first if the file exists via the exists() method
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
off_t size (string const& path);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief strip extension
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -68,7 +68,7 @@ static void CheckPidFile (string const& pidFile) {
|
|||
TRI_FlushLogging();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (FileUtils::exists(pidFile)) {
|
||||
else if (FileUtils::exists(pidFile) && FileUtils::size(pidFile) > 0) {
|
||||
LOGGER_INFO << "pid-file '" << pidFile << "' already exists, verifying pid";
|
||||
|
||||
ifstream f(pidFile.c_str());
|
||||
|
@ -137,7 +137,7 @@ static void WritePidFile (string const& pidFile, int pid) {
|
|||
ofstream out(pidFile.c_str(), ios::trunc);
|
||||
|
||||
if (! out) {
|
||||
cerr << "cannot write pid\n";
|
||||
cerr << "cannot write pid-file \"" << pidFile << "\"\n";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,9 @@ static int forkProcess (string const& pidFile, string const& workingDirectory, s
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Upon successful completion, fork() shall return 0 to the child process and
|
||||
// shall return the process ID of the child process to the parent process.
|
||||
|
||||
// if we got a good PID, then we can exit the parent process
|
||||
if (pid > 0) {
|
||||
LOGGER_DEBUG << "started child process with pid " << pid;
|
||||
|
|
Loading…
Reference in New Issue