Can't deploy app because of database connection error - ruby-on-rails-4

does anyone know why I can't deploy my application? I'm using the exact same configuration/changes I did to my other app which I can deploy to cc without any problems (different credentials, of course).
database.yml:
production:
adapter: postgresql
encoding: unicode
reconnect: false
pool: 3
database: xxx
host: horton.elephantsql.com
port: 5432
username: xxx
password: xxx
This is the error message I get:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
/srv/tmp/builddir/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `initialize'
/srv/tmp/builddir/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `new'
/srv/tmp/builddir/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `connect'
Any suggestions?

Since during push the Add-on credentials are not yet available (they're only available during run-time) you have to set the following option to tell Rails to not try to initialize the database during asset precompilation.
config.assets.initialize_on_precompile = false if ENV['BUILDPACK_RUNNING']
You can find this and other Rails related settings here: https://www.cloudcontrol.com/dev-center/Guides/Ruby/RubyNotes.

Related

connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "postgres"

I'm trying to set up Django PostgreSQL in Django application. I created the db, user and password for the user and when I run \l I can see the db. When I run the django app with python manage.py runserver i get the following error messages.
ON PURE START UP
USER TABLE NOT EXIST
connection to server at "localhost" (127.0.0.1), port 5432 failed: could not initiate GSSAPI security context: Unspecified GSS failure. Minor code may provide more information: Server not found in Kerberos database
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "postgres"
What am I missing

capistrano doesn't respect port

I'm deploying to production as follow:
HOSTS = [
'api1.app.io',
'api2.app.io',
'api3.app.io',
'api4.app.io',
'api5.app.io',
'api6.app.io',
'api7.app.io',
'api8.app.io',
'api9.app.io',
'api10.app.io'
].freeze
HOSTS.each do |host|
server host, roles: %i[app web], user: 'deploy', port: 2323
end
although it fails when capistrano tries to ssh into the servers because it still tries to connect using port 22...
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host api2.app.io: Net::SSH::ConnectionTimeout
Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout
Errno::ETIMEDOUT: Connection timed out - connect(2) for xx.xx.xx.xx:22
Is there any other way to configure the ports?
The :port option should work. If it does not, that it is a bug. Please open a bug report at https://github.com/capistrano/capistrano/issues .
As a workaround, you can also specify the port via the hostname using the <host>:<port> syntax, like this:
HOSTS.each do |host|
server "#{host}:#{port}", roles: %i[app web], user: 'deploy'
end

Something wrong on deploy chaincode for hyperledger v1.0

I have tried to use docker toolbox to setup Hyperledger V1.0 in my local machines.
I according to this document:
http://hyperledger-fabric.readthedocs.io/en/latest/asset_setup.html
But when I tried to deploy chaincode.
$node deploy.js
I got an error message:
info: Returning a new winston logger with default configurations
info: [Chain.js]: Constructed Chain instance: name - fabric-client1, securityEnabled: true, TCert download batch size: 10, network mode: true
info: [Peer.js]: Peer.const - url: grpc://localhost:8051 options grpc.ssl_target_name_override=tlsca, grpc.default_authority=tlsca
info: [Peer.js]: Peer.const - url: grpc://localhost:8055 options grpc.ssl_target_name_override=tlsca, grpc.default_authority=tlsca
info: [Peer.js]: Peer.const - url: grpc://localhost:8056 options grpc.ssl_target_name_override=tlsca, grpc.default_authority=tlsca
info: [Client.js]: Failed to load user "admin" from local key value store
info: [FabricCAClientImpl.js]: Successfully constructed Fabric COP service client: endpoint - {"protocol":"http","hostname":"localhost","port":8054}
info: [crypto_ecdsa_aes]: This class requires a KeyValueStore to save keys, no store was passed in, using the default store C:\Users\daniel\.hfc-key-store
[2017-04-15 22:14:29.268] [ERROR] Helper - Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:8054]
at ClientRequest.<anonymous> (C:\Users\daniel\node_modules\fabric-ca-client\lib\FabricCAClientImpl.js:304:12)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1278:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
[2017-04-15 22:14:29.273] [ERROR] DEPLOY - Error: Failed to obtain an enrolled user
at ca_client.enroll.then.then.then.catch (C:\Users\daniel\helper.js:59:12)
at process._tickCallback (internal/process/next_tick.js:103:7)
events.js:160
throw er; // Unhandled 'error' event
^
Error: Connect Failed
at ClientDuplexStream._emitStatusIfDone (C:\Users\daniel\node_modules\grpc\src\node\src\client.js:201:19)
at ClientDuplexStream._readsDone (C:\Users\daniel\node_modules\grpc\src\node\src\client.js:169:8)
at readCallback (C:\Users\daniel\node_modules\grpc\src\node\src\client.js:229:12)
Is this an question about unable to connect to ca? Or other causes?
Edit:
Environment:
OS: Windows 10 Professional Edition
Docker Toolbox: 17.04.0-ce
Go: 1.7.5
Node.js: 6.10.0
My steps:
1.Open Docker Quickstart Terminal and key commands.
$curl -L https://raw.githubusercontent.com/hyperledger/fabric/master/examples/sfhackfest/sfhackfest.tar.gz -o sfhackfest.tar.gz 2> /dev/null; tar -xvf sfhackfest.tar.gz
$docker-compose -f docker-compose-gettingstarted.yml build
$docker-compose -f docker-compose-gettingstarted.yml up -d
$docker ps
It has been confirmed that six containers have been activated
2.Download examples and install modules.
$curl -OOOOOO https://raw.githubusercontent.com/hyperledger/fabric-sdk-node/v1.0-alpha/examples/balance-transfer/{config.json,deploy.js,helper.js,invoke.js,query.js,package.json}
//This link didn't work, so I downloaded the required files from GitHub of fabric-sdk-node
$npm install --global windows-build-tools
$npm install
3.Try to deploy chaincode.
$node deploy.js
There were several problems, not the least of which that documentation was outdated and was for a preview release of Hyperledger Fabric. The docs are actually in the process of being removed as we need to update our examples / samples.
You mentioned Docker Toolbox - so are you trying to run all of this on Windows or Mac?
UPDATE:
So one of the issue with Docker Toolbox or Docker for Windows is that you cannot use localhost / 127.0.0.1 as the address when trying to communicate from apps on the host (even in the QuickStart Terminal) to the endpoints of the Docker containers. When the QuickStart Terminal first launches Docker, you'll see that it will output the IP address of the endpoint you should use when communicating with exposed ports.
I was having the same issue while following the latest "Writing Your First Application" tutorial (http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html). I had installed all the pre-requisites and the fabric-samples and started the local network.
When I got to the step of enrolling the Admin user, $ node enrollAdmin.js, I was getting the same error message as above, Error: connect ECONNREFUSED, followed by the localhost domain.
As the first answer suggests, the root cause is that I'm running Docker Toolbox. I'm developing on an older Mac, OSX v10.9.5, so I couldn't use Docker for Mac.
To fix the issue, I replaced 'localhost' in the enrollAdmin.js code with the IP from Docker Toolbox.
Here are the steps I took:
Started Docker with Applications > Docker Quickstart Terminal
Copied the IP from this sentence: docker is configured to use the default machine with IP...
Opened the copy of enrollAdmin.js from fabric-samples/fabcar directory
Found this code:
// be sure to change the http to https when the CA is running TLS enabled
fabric_ca_client = new Fabric_CA_Client('http://localhost:7054', tlsOptions , 'ca.example.com', crypto_suite); // <-- This is the line to change
Replaced 'localhost' with the Docker IP, leaving the port :7054 as is.
Saved
Re-ran the command, $ node enrollAdmin.js
The script connected to the CA and successfully completed the Admin enrollment.
On to the next step!

How to connect to redis with dokku and flask?

I wanted to use redis with dokku and flask. First issue was installing current version of dokku, i am using latest version from repo now.
Second problem is showing in Flask debugger:
redis.exceptions.ConnectionError
ConnectionError: Error 111 connecting to None:6379. Connection refused.
I set redis url and port in Flask:
app.config['REDIS_URL'] = 'IP:32768'
-----> Checking status of Redis
remote: Found image redis/landing
remote: Checking status...stopped.
remote: Launching redis/landing...COMMAND: docker run -v /home/dokku/.redis/volume-landing:/var/lib/redis -p 6379 -d redis/landing /bin/start_redis.sh
-----> Setting config vars
REDIS_URL: redis://IP:6379
REDIS_IP: IP
REDIS_PORT: 6379
Any idea? REDIS_URL should be set in different way?
This code works ok in localhost:
https://github.com/kwikiel/bounce
(with ['REDIS_IP'] = '172.17.0.13' set to 127.0.0.1)
Problem appears when i try to connect with redis dokku.
Steps to use redis with flask and dokku:
Install redis plugin:
cd /var/lib/dokku/plugins
git clone https://github.com/ohardy/dokku-redis redis
dokku plugins-install
Link your redis container to application container
dokku redis:create [name of app container]
You will receive info about environmental variables that you will have to set - for example:
Host: 172.17.0.91
Public port: 32771
Then set these settings in Flask (or other framework)
app.config['REDIS_URL'] = 'redis://172.17.0.91:6379'
app.config['REDIS_IP'] = '172.17.0.91'
app.config['REDIS_PORT'] = '6379'
Complete example of redis database used with Flask app (A/B testing in Flask):
https://github.com/kwikiel/bounce

Unable to login to https://api.cloudfoundry.com

despite the fact that i have setup everything i am still unable to login:
C:>vmc target
[https://api.cloudfoundry.com]
C:> vmc info
VMware's Cloud Application Platform
For support visit http://support.cloudfoundry.com
Target: https://api.cloudfoundry.com (v0.999)
Client: v0.3.23
C:>vmc login xxxxxxxxxxx -t
Attempting login to [https://api.cloudfoundry.com]
Password: **
Problem with login to 'https://api.cloudfoundry.com', A connection attempt failed because the connected party did not pr
operly respond after a period of time, or established connection failed because connected host has failed to respond. -
connect(2), try again or register for an account.
Has anyone an idea what I am possibly missing here?
Please update your vmc client
gem update vmc