From c78e9af4b6880aa603dc1dde8d5b742eeaae8676 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 18 Aug 2014 23:18:45 -0700 Subject: [PATCH] gce: run mysql too. link it with camlistored. I think I'm not using systemd correctly here. Things get very unhappy if I reboot CoreOS: the Docker container named 'db' already exists, things keep flapping up and down (not waiting for their dependencies), etc. Maybe I need to register stop actions too. Change-Id: I75ac3e965c03df4f7f3938ff13c66f137948bf4d --- misc/gce/create.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/misc/gce/create.go b/misc/gce/create.go index 260c94336..47edd9cc3 100644 --- a/misc/gce/create.go +++ b/misc/gce/create.go @@ -103,16 +103,31 @@ coreos: [Install] WantedBy=sockets.target + - name: mysql.service + command: start + content: | + [Unit] + Description=MySQL + After=docker.service + Requires=docker.service + + [Service] + ExecStart=/usr/bin/docker run --name=db google/mysql + RestartSec=500ms + Restart=always + + [Install] + WantedBy=multi-user.target - name: camlistored.service command: start content: | [Unit] Description=Camlistore After=docker.service - Requires=docker.service + Requires=docker.service mysql.service [Service] - ExecStart=/usr/bin/docker run -p 80:80 -p 443:443 -v /run/camjournald.sock:/run/camjournald.sock -v /tmp/camlistore-tmp:/tmp camlistore/camlistored + ExecStart=/usr/bin/docker run -p 80:80 -p 443:443 -v /run/camjournald.sock:/run/camjournald.sock -v /tmp/camlistore-tmp:/tmp --link=db:mysqldb camlistore/camlistored RestartSec=500ms Restart=always @@ -120,6 +135,10 @@ coreos: WantedBy=multi-user.target ` + const maxCloudConfig = 32 << 10 // per compute API docs + if len(cloudConfig) > maxCloudConfig { + log.Fatalf("cloud config length of %d bytes is over %d byte limit", len(cloudConfig), maxCloudConfig) + } if *sshPub != "" { key := strings.TrimSpace(readFile(*sshPub)) cloudConfig += fmt.Sprintf("\nssh_authorized_keys:\n - %s\n", key)