Skip to content

Instantly share code, notes, and snippets.

@israelfaria
Created March 29, 2016 17:23
Show Gist options
  • Save israelfaria/d47094551b1afe6c7f125cb749882f9e to your computer and use it in GitHub Desktop.
Save israelfaria/d47094551b1afe6c7f125cb749882f9e to your computer and use it in GitHub Desktop.
How to use GCE SQL Proxy as service in Ubuntu 15.10 images
[Unit]
Description=Google Cloud Compute Engine SQL Proxy
After=cloud-config.target
Wants=cloud-config.target
[Service]
Type=simple
ExecStartPre=/bin/mkdir -p /run/cloudsqlproxy
#Optional steps if you wanna link default mysqld socket to an instance
ExecStartPre=/bin/mkdir -p /run/mysqld
ExecStartPre=/bin/ln -s /run/cloudsqlproxy/<<YOUR-PROJECT>>:<<REGION>>:<<SQL-INSTANCE>> /run/mysqld/mysqld.sock
ExecStart=/usr/bin/daemon -n cloudsqlproxy
ExecReload=/usr/bin/daemon -n cloudsqlproxy --restart
ExecStop=/usr/bin/daemon -n cloudsqlproxy --stop
[Install]
WantedBy=multi-user.target
# /etc/daemon.conf: system-wide daemon(1) configuration.
# See daemon(1) for full documentation.
# Format: <name|"*"> <option(","option)*>
cloudsqlproxy output=local0.debug,respawn,command=cloudsqlproxy -fuse -dir=/run/cloudsqlproxy
#!/bin/bash
wget -O /usr/local/bin/cloudsqlproxy https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64
apt-get install daemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment