[couchdb-glib] DesktopcouchService: Add code to read the PID from the couchdb PID file
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [couchdb-glib] DesktopcouchService: Add code to read the PID from the couchdb PID file
- Date: Fri, 22 Jul 2011 09:38:51 +0000 (UTC)
commit bcbc9221a5d81977d21bdab1dcfd94cc6018eed2
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Thu Jun 16 13:09:46 2011 +0200
DesktopcouchService: Add code to read the PID from the couchdb PID file
desktopcouch-glib/desktopcouch-service.c | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/desktopcouch-glib/desktopcouch-service.c b/desktopcouch-glib/desktopcouch-service.c
index 5af3a54..dda81f8 100644
--- a/desktopcouch-glib/desktopcouch-service.c
+++ b/desktopcouch-glib/desktopcouch-service.c
@@ -43,7 +43,7 @@ desktopcouch_service_finalize (GObject *object)
g_spawn_close_pid (service->priv->pid);
}
-
+
G_OBJECT_CLASS (desktopcouch_service_parent_class)->finalize (object);
}
@@ -81,6 +81,7 @@ spawn_couchdb (DesktopcouchService *service)
gchar *couchdb_args[7], *data_dir;
GError *error = NULL;
+ /* Spawn CouchDB process */
couchdb_args[0] = "couchdb";
couchdb_args[1] = "-a";
couchdb_args[2] = g_build_filename (g_get_user_config_dir (), service->priv->instance_name, "desktopcouch.ini", NULL);
@@ -92,14 +93,24 @@ spawn_couchdb (DesktopcouchService *service)
data_dir = g_build_filename (g_get_user_data_dir (), service->priv->instance_name, NULL);
if (g_spawn_async (data_dir,
- couchdb_args,
- NULL,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL,
- NULL,
- &service->priv->pid,
- &error)) {
- g_child_watch_add (service->priv->pid, (GChildWatchFunc) couchdb_watch_cb, service);
+ couchdb_args,
+ NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL,
+ NULL,
+ &service->priv->pid,
+ &error)) {
+ gchar *contents;
+ gsize size;
+
+ /* Read the PID file to get the process ID to watch */
+ error = NULL;
+ if (g_file_get_contents (couchdb_args[5], &contents, &size, &error)) {
+ service->priv->pid = atoi (contents);
+ g_child_watch_add (service->priv->pid, (GChildWatchFunc) couchdb_watch_cb, service);
+
+ g_free (contents);
+ }
} else {
g_print ("Error spawning couchdb: %s\n", error->message);
g_error_free (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]