Created
March 29, 2016 17:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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