Last active
September 7, 2022 17:16
-
-
Save generalpiston/759ab8d0acd4c4e432625fdf92798ade to your computer and use it in GitHub Desktop.
launchctl plist config for google cloud_sql_proxy
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" | |
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.google.cloud_sql_proxy</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string><cloud_sql_proxy path>/cloud_sql_proxy</string> | |
<string>-dir=/var/lib/cloudsql</string> | |
<string>-instances=<connection name>,...</string> | |
<string>-log_debug_stdout</string> | |
<string>-enable_iam_login</string> | |
<string>-verbose</string> | |
</array> | |
<key>StandardOutPath</key> | |
<string>/var/log/cloud_sql_proxy/cloud_sql_proxy.output</string> | |
<key>StandardErrorPath</key> | |
<string>/var/log/cloud_sql_proxy/cloud_sql_proxy.error</string> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> |
Updates should be made to the plist file;
- update cloud_sql_proxy path (normally /usr/local/bin)
- and set to instances found in cloud_sql.
example: -instances=datacy-production:us-central1:datacy-metadata,datacy-production:us-central1:datacy-data,datacy-production:us-central1:datacy-data-replica1,datacy-dev-319809:us-central1:datacy-metadata,datacy-dev-319809:us-central1:datacy-data
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes the cloud_sql_proxy binary was installed. I recommend putting it in
/usr/local/bin
.The above file should go into:
~/Library/LaunchAgents/com.google.cloud_sql_proxy.plist
.Also, make sure permissions are right:
Then load the config into launchctl:
Examples
Connecting to PostgreSQL using the CLI client
Database URL for connecting to PostgreSQL in node.js