15
#include "glusterd-utils.h"
16
#include <glusterfs/common-utils.h>
17
#include <glusterfs/logging.h>
18
#include "glusterd-messages.h"
19
#include "glusterd-proc-mgmt.h"
22
glusterd_proc_init(glusterd_proc_t *proc, char *name, char *pidfile,
23
char *logdir, char *logfile, char *volfile, char *volfileid,
28
ret = snprintf(proc->name, sizeof(proc->name), "%s", name);
32
ret = snprintf(proc->pidfile, sizeof(proc->pidfile), "%s", pidfile);
36
ret = snprintf(proc->logdir, sizeof(proc->logdir), "%s", logdir);
40
ret = snprintf(proc->logfile, sizeof(proc->logfile), "%s", logfile);
44
ret = snprintf(proc->volfile, sizeof(proc->volfile), "%s", volfile);
48
ret = snprintf(proc->volfileid, sizeof(proc->volfileid), "%s", volfileid);
52
ret = snprintf(proc->volfileserver, sizeof(proc->volfileserver), "%s",
65
glusterd_proc_stop(glusterd_proc_t *proc, int sig, int flags)
72
xlator_t *this = THIS;
73
glusterd_conf_t *conf = NULL;
79
if (!gf_is_service_running(proc->pidfile, &pid)) {
81
gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_ALREADY_STOPPED,
82
"%s already stopped", proc->name);
85
gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_STOP_SUCCESS,
86
"Stopping %s daemon running in pid: "
94
gf_msg_debug(this->name, 0,
101
gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_SVC_KILL_FAIL,
103
"service, reason:%s",
104
proc->name, strerror(errno));
107
gf_unlink(proc->pidfile);
109
if (flags != PROC_STOP_FORCE)
112
for (tries = 10; tries > 0; --tries) {
113
if (gf_is_service_running(proc->pidfile, &pid)) {
114
synclock_unlock(&conf->big_lock);
115
synctask_usleep(100000);
116
synclock_lock(&conf->big_lock);
123
if (gf_is_service_running(proc->pidfile, &pid)) {
124
ret = kill(pid, SIGKILL);
126
gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_PID_KILL_FAIL,
127
"Unable to kill pid:%d, "
129
pid, strerror(errno));
132
gf_unlink(proc->pidfile);
141
glusterd_proc_get_pid(glusterd_proc_t *proc)
144
(void)gf_is_service_running(proc->pidfile, &pid);
149
glusterd_proc_is_running(glusterd_proc_t *proc)
153
return gf_is_service_running(proc->pidfile, &pid);