[gnome-builder/gnome-builder-3-32] podman: start podman container at least once
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-32] podman: start podman container at least once
- Date: Wed, 3 Apr 2019 21:16:53 +0000 (UTC)
commit f5a25a1abed3369188820ec309ab195cc8b07d4f
Author: Christian Hergert <chergert redhat com>
Date: Wed Apr 3 14:15:34 2019 -0700
podman: start podman container at least once
When creating a subprocess launcher, we should try to first
start the container so it is ready by time the launcher is used.
Only do this once to avoid restarts when the container is
failing.
src/plugins/podman/gbp-podman-runtime.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
---
diff --git a/src/plugins/podman/gbp-podman-runtime.c b/src/plugins/podman/gbp-podman-runtime.c
index 6a2e6ee7f..40fd83b55 100644
--- a/src/plugins/podman/gbp-podman-runtime.c
+++ b/src/plugins/podman/gbp-podman-runtime.c
@@ -31,10 +31,41 @@ struct _GbpPodmanRuntime
{
IdeRuntime parent_instance;
JsonObject *object;
+ guint has_started : 1;
};
G_DEFINE_TYPE (GbpPodmanRuntime, gbp_podman_runtime, IDE_TYPE_RUNTIME)
+static void
+maybe_start (GbpPodmanRuntime *self)
+{
+ g_autoptr(IdeSubprocessLauncher) launcher = NULL;
+ g_autoptr(IdeSubprocess) subprocess = NULL;
+ const gchar *id;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_PODMAN_RUNTIME (self));
+
+ if (self->has_started)
+ return;
+
+ if (!(id = json_object_get_string_member (self->object, "ID")))
+ return;
+
+ launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDERR_SILENCE |
+ G_SUBPROCESS_FLAGS_STDOUT_SILENCE);
+ ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
+ ide_subprocess_launcher_push_argv (launcher, "podman");
+ ide_subprocess_launcher_push_argv (launcher, "start");
+ ide_subprocess_launcher_push_argv (launcher, id);
+
+ if ((subprocess = ide_subprocess_launcher_spawn (launcher, NULL, NULL)))
+ {
+ ide_subprocess_wait_async (subprocess, NULL, NULL, NULL);
+ self->has_started = TRUE;
+ }
+}
+
static IdeSubprocessLauncher *
gbp_podman_runtime_create_launcher (IdeRuntime *runtime,
GError **error)
@@ -44,6 +75,8 @@ gbp_podman_runtime_create_launcher (IdeRuntime *runtime,
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_PODMAN_RUNTIME (self));
+ maybe_start (self);
+
return g_object_new (GBP_TYPE_PODMAN_SUBPROCESS_LAUNCHER,
"id", json_object_get_string_member (self->object, "ID"),
"run-on-host", TRUE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]