process_restart more gracefully

iovec_array
YuQing 2021-06-04 17:56:02 +08:00
parent e068391c87
commit 1d1a766c70
3 changed files with 10 additions and 6 deletions

View File

@ -75,7 +75,7 @@ typedef struct tagConnectionPool {
int max_count_per_entry; //0 means no limit
/*
connections whose the idle time exceeds this time will be closed
connections whose idle time exceeds this time will be closed
unit: second
*/
int max_idle_time;

View File

@ -112,7 +112,7 @@ static int do_stop(const char *pidFilename, const bool bShowError, pid_t *pid)
}
}
int process_stop(const char *pidFilename)
int process_stop_ex(const char *pidFilename, const bool bShowError)
{
#define MAX_WAIT_COUNT 300
pid_t pid;
@ -120,7 +120,7 @@ int process_stop(const char *pidFilename)
int sig;
int i;
if ((result=do_stop(pidFilename, true, &pid)) != 0) {
if ((result=do_stop(pidFilename, bShowError, &pid)) != 0) {
return result;
}
@ -148,9 +148,10 @@ int process_stop(const char *pidFilename)
int process_restart(const char *pidFilename)
{
const bool bShowError = false;
int result;
result = process_stop(pidFilename);
result = process_stop_ex(pidFilename, bShowError);
if (result == ENOENT || result == ESRCH) {
result = 0;
} else if (result == 0) {
@ -328,6 +329,7 @@ int get_base_path_from_conf_file(const char *filename, char *base_path,
int process_action(const char *pidFilename, const char *action, bool *stop)
{
const bool bShowError = true;
*stop = false;
if (action == NULL)
{
@ -337,7 +339,7 @@ int process_action(const char *pidFilename, const char *action, bool *stop)
if (strcmp(action, "stop") == 0)
{
*stop = true;
return process_stop(pidFilename);
return process_stop_ex(pidFilename, bShowError);
}
else if (strcmp(action, "restart") == 0)
{

View File

@ -36,7 +36,9 @@ int write_to_pid_file(const char *pidFilename);
int delete_pid_file(const char *pidFilename);
int process_stop(const char *pidFilename);
int process_stop_ex(const char *pidFilename, const bool bShowError);
#define process_stop(pidFilename) process_stop_ex(pidFilename, true)
int process_restart(const char *pidFilename);