To test the connection from one of our servers, you will first need to ssh into the server. To ssh into Web1 or Web2, you can use the following command (assuming you have the github repo downloaded and the key file permissions set correctly).
ssh -i config/deploy/keys/deploy [email protected]
or
ssh -i config/deploy/keys/deploy [email protected]
Websites
SFTP
sftp -oPort=<port> <username>@<hostname>
You will then be prompted for the password.
FTP
ftp <hostname> <port>
You will then be prompted for the username and password.
Console
Run the following command to start the rails console.
cd /data/codeguard/current && RAILS_ENV=production script/console
Then run the following command in the rails console to test the connection.
Website.find(<website_id>).connectable?
Databases
SSH
If the connection is tunneled over ssh, the following command will allow you to manually log in to the SSH server.
ssh -p <port> <ssh_user>@<ssh_hostname>
You will then be prompted for the password.
MySQL
mysql -h<hostname> -u<username> -p <database_name>
You will then be prompted for the password.
Tunneled MySQL
In addition to testing SSH and MySQL separately, you can also test them both at once. This way of testing the connection is more analogous to the way we connect from our application.
First open an SSH tunnel.
ssh -p <port> <ssh_user>@<ssh_hostname> -L 65000:127.0.0.1:3306 -N
Then in a separate session, open the MySQL connection through the tunnel.
mysql -h127.0.0.1 -u<username> -p <database_name> -P 65000
Console
Run the following command to start the rails console.
cd /data/codeguard/current && RAILS_ENV=production script/console
Then run one of the following commands in the rails console to test the connection.
DatabaseBackup.find(<database_id>).test_connection
DatabaseBackup.find(<database_id>).test_credentials