process_restart more gracefully
parent
e068391c87
commit
1d1a766c70
|
|
@ -75,7 +75,7 @@ typedef struct tagConnectionPool {
|
||||||
int max_count_per_entry; //0 means no limit
|
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
|
unit: second
|
||||||
*/
|
*/
|
||||||
int max_idle_time;
|
int max_idle_time;
|
||||||
|
|
|
||||||
|
|
@ -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
|
#define MAX_WAIT_COUNT 300
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
@ -120,7 +120,7 @@ int process_stop(const char *pidFilename)
|
||||||
int sig;
|
int sig;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((result=do_stop(pidFilename, true, &pid)) != 0) {
|
if ((result=do_stop(pidFilename, bShowError, &pid)) != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,9 +148,10 @@ int process_stop(const char *pidFilename)
|
||||||
|
|
||||||
int process_restart(const char *pidFilename)
|
int process_restart(const char *pidFilename)
|
||||||
{
|
{
|
||||||
|
const bool bShowError = false;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = process_stop(pidFilename);
|
result = process_stop_ex(pidFilename, bShowError);
|
||||||
if (result == ENOENT || result == ESRCH) {
|
if (result == ENOENT || result == ESRCH) {
|
||||||
result = 0;
|
result = 0;
|
||||||
} else if (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)
|
int process_action(const char *pidFilename, const char *action, bool *stop)
|
||||||
{
|
{
|
||||||
|
const bool bShowError = true;
|
||||||
*stop = false;
|
*stop = false;
|
||||||
if (action == NULL)
|
if (action == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -337,7 +339,7 @@ int process_action(const char *pidFilename, const char *action, bool *stop)
|
||||||
if (strcmp(action, "stop") == 0)
|
if (strcmp(action, "stop") == 0)
|
||||||
{
|
{
|
||||||
*stop = true;
|
*stop = true;
|
||||||
return process_stop(pidFilename);
|
return process_stop_ex(pidFilename, bShowError);
|
||||||
}
|
}
|
||||||
else if (strcmp(action, "restart") == 0)
|
else if (strcmp(action, "restart") == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ int write_to_pid_file(const char *pidFilename);
|
||||||
|
|
||||||
int delete_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);
|
int process_restart(const char *pidFilename);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue