I'm trying to connect my application to Shared Database 5MB using grails tutorial. I'm using grails 2.1.0. On my local machine when I run heroku config I can see that DATABASE_URL is set, but after executing git push... my build stops with error:
Error packaging application: Error loading DataSource.groovy: null (Use --stacktrace to see the full trace)
Failed to build app
Heroku push rejected, failed to compile Grails app
So I've added logging to see how environment looks on heroku. I've added println System.env to Datasource.groovy and I cannot find any DATABASE_URL:
.[OLDPWD:/app/tmp/repo.git/.cache, SHELL:/bin/bash, SHLVL:2, GIT_DIR:., JAVA_HOME:/usr/lib/jvm/java-6-openjdk, PATH:/app/tmp/repo.git/.cache/.grails/bin::/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin, SSH_CLIENT:XXX, MAIL:XXX, USER:XXX, LOG_TOKEN:t.9e79a5be-dfa2-446e-9f83-f6b4ebbc4eb7, GRAILS_HOME:/app/tmp/repo.git/.cache/.grails, PWD:XXX, HOME:/app/, LOGNAME:u11846, _:/app/tmp/repo.git/.cache/.grails/bin/grails, SSH_CONNECTION:XXX, LD_LIBRARY_PATH:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64]
I have checked with heroku addons that for my application shared database is installed:
heroku addons
=== XXX Configured Add-ons
shared-database:5mb
and when I execute heroku config
heroku config
=== Config Vars for XXX
DATABASE_URL: postgres://XXX
JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops
SHARED_DATABASE_URL: postgres://XXX
Datasource.groovy:
production {
dataSource {
dbCreate = "update"
driverClassName = "org.postgresql.Driver"
dialect = org.hibernate.dialect.PostgreSQLDialect
println System.env
println System.env.DATABASE_URL
uri = new URI(System.env.DATABASE_URL)
println uri
url = "jdbc:postgresql://" + uri.host + uri.path
username = uri.userInfo.split(":")[0]
password = uri.userInfo.split(":")[1]
}
}
In BuildConfig.groovy I've added
runtime 'postgresql:postgresql:8.4-702.jdbc3'
I can launch application locally with DATABASE_URL set to local postgresql. I'm building war and running it on jetty.
Can anyone tell me what am I missing?
The application environment variables are not available at build time. Your code needs to be able to handle that accordingly. Or you can enable the new user_env_compile Heroku Labs feature that does enable the environment variables to be there at build time: https://devcenter.heroku.com/articles/labs-user-env-compile
Related
In my Heroku environment where I deploy my NestJS application, I set all my Config Vars through the Heroku UI. I have set my NODE_ENV config var to staging using the Heroku UI. I've even ran this command heroku config:set NODE_ENV=staging -a <my-staging-environment. When I run heroku config -a <my-staging-environment>, I see that NODE_ENV is set to staging, but for whatever reason, when I console.log this variable from my code, it outputs development. Below is some example code where it is logs development as the value for NODE_ENV in my TypeOrm configuration. This is causing the ssl property to not get set to the correct value, and I cannot connect to my Heroku Postgres database because of it. I only intend to set it to development for local development purposes.
require('dotenv').config();
console.log(process.env.NODE_ENV); // outputs "development" - idk where this value is coming from
console.log(process.env.DATABASE_URL); // outputs the correct value that I set in Heroku Config Vars
const typeOrmConfig: TypeOrmModuleOptions = {
type: 'postgres',
url: process.env.DATABASE_URL,
ssl: process.env.NODE_ENV !== 'development' ? { rejectUnauthorized: false } : false, // ternary evaluates to the wrong value
// ... other config options
};
I use dotenv, and I made sure to .gitignore my .env file. I don't recall ever setting this variable to development. The only place I see it set to NODE_ENV=development in my code is in my .env-example file. I do commit this file to source control, but it's just an example file and not a real .env file and it shouldn't actually be being used.
Does anyone have any idea why this is happening?
I have found that it is not a Heroku issue. Rather it is a NestJS/Nx issue.
See:
process.env.NODE_ENV always 'development' when building nestjs app with nrwl nx
I'm trying to setup SonarQube for a Gradle project. I get it to play locally, but when using Travis CI I, run into problems. Travis cannot reach the SonarQube server through the HAProxy.
SonarQube server is behind a HAProxy with Basic Access Authentication. I have tried to use the name and password both as sonar.login/sonar.password and as auth credentials in the URL, but with no success.
sonarqubeSonarQube server [https://sonar.<domain>.com] can not be reached
or
sonarqubeSonarQube server [https://<name>:<password>#sonar.<domain>.com] can not be reached
Basically my build.gradle file contains this:
plugins {
id "org.sonarqube" version "2.0.1"
}
sonarqube {
properties {
properties["sonar.host.url"] = getProperty('SONAR_URL')
properties["sonar.login"] = getProperty('SONAR_USERNAME')
properties["sonar.password"] = getProperty('SONAR_PASSWORD')
}
}
I had to remove the 'systemProp.' prefix to the properties in order to get it to work locally.
When running locally, I have a init.gradle file that contains this section, and it works nice.
allprojects {
ext.set('SONAR_URL', 'http://localhost:9000')
ext.set('SONAR_USERNAME', 'admin')
ext.set('SONAR_PASSWORD', 'admin')
...
}
On Travis CI, I try to add environment variables for the job:
ORG_GRADLE_PROJECT_SONAR_PASSWORD ••••••••••••••••
ORG_GRADLE_PROJECT_SONAR_USERNAME ••••••••••••••••
ORG_GRADLE_PROJECT_SONAR_URL ••••••••••••••••
How can I get Travis CI to reach the sonar server that we have?
I am using Bluemix to run app, I can deploy Java app to Bluemix, does anyone know how to deploy a Go App to Bluemix?
You can deploy a Go application to Bluemix, but need to supply -b with the Go Buildpack URL.
There is a sample application you can take a look:
https://github.com/acostry/Go-on-Bluemix
You need to use a custom buildpack to deploy a Go web application. So, login to your cloud and run the cf command below from the root folder of your application:
cf push appname -b https://github.com/cloudfoundry/cloudfoundry-buildpack-go
Actually, Bluemix now includes the Cloud Foundry Go buildpack https://github.com/cloudfoundry/go-buildpack in its catalog. Hence, it should be unnecessary to resort to use of the BYOB feature.
API endpoint: https://api.ng.bluemix.net (API version: 2.19.0)
mbp:utils cbf$ cf buildpacks
Getting buildpacks...
buildpack position enabled locked filename
liberty-for-java 1 true false buildpack_liberty-for-java_v1.15-20150402-1422-yp.zip
sdk-for-nodejs 2 true false buildpack_sdk-for-nodejs_v1.15-20150331-2231-yp.zip
noop-buildpack 3 true false noop-buildpack-20140311-1519.zip
java_buildpack 4 true false java-buildpack-v2.6.zip
ruby_buildpack 5 true false ruby_buildpack-offline-v1.2.0.zip
nodejs_buildpack 6 true false nodejs_buildpack-offline-v1.1.1.zip
go_buildpack 7 true false go_buildpack-offline-v1.1.1.zip
python_buildpack 8 true false python_buildpack-offline-v1.1.1.zip
php_buildpack 9 true false php_buildpack-offline-v1.0.2.zip
liberty-for-java_v1-14-20150319-1159 10 true false buildpack_liberty-for-java_v1.14-20150319-1159-yp.zip
sdk-for-nodejs_v1-14-20150309-1555 11 true false buildpack_sdk-for-nodejs_v1.14-20150309-1555-yp.zip
Just to be clear the full command would be the following.
cf push appname -b https://github.com/cloudfoundry/go-buildpack.git
You have to include "-b" option while pushing your go app on Bluemix cloud.
cf push app_name -b buildpack_URL
For any other types of app, you can refer below link for pushing app on bluemix:
https://www.ng.bluemix.net/docs/#starters/byob.html.
Issue the following command with the -b option to deploy your application with your own buildpack, in which buildpack_URL is the URL of the buildpack:
$ cf push app_name -b buildpack_URL
More specifically
cf push app_name -b https://github.com/cloudfoundry/go-buildpack.git
more info is below:
https://www.ng.bluemix.net/docs/#starters/byob.html.
Deploying the app to Bluemix is pretty much the same as deploying any other app, with the exception of a command-line flag to set the custom buildpack the platform should use to provision the runtime.
Log in to your Bluemix account and run this command from the root folder of your application, where appname represents a unique name for your Bluemix-hosted app:
cf push appname -b url
More details regrading creating/pushing/deploying/connecting can be found at http://www.ibm.com/developerworks/cloud/library/cl-bluemix-go-app/
I'm writing a WLST script to deploy an application with WebLogic 11g. The problem is that when I deploy an application (version A), undeploy it, then deploy version B, it deploys version A.
If I try to solve this by deleting the tmp/_WL_user/appname/ folder, it then won't deploy A or B because it looks in the tmp folder for the application (and fails because I cleared it out). I'm using the nostage option, so I don't understand why it's caching anything.
Any help you can offer would be greatly appreciated. Thanks!
Probably the undeploy of Version A was not successful and Version B was never deployed.
Not sure what you have in the WLST script, could you try with the following:
# let's say the appName is testApp
# can move all of these properties to a props file
appName='testApp'
appPath='/scratch/user/testApp.war'
appTarget='AdminServer'
username='weblogic'
password='weblogic1'
adminURL='t3://hostname:adminport'
# start deploy/undeploy code
connect (username, password, adminURL)
for app in cmo.getAppDeployments():
currAppName = app.getName()
if currAppName == appName :
print('Application' + appName + ' already exists, undeploying...')
undeploy(appName)
# sleep is just to make sure that we don't attempt deploy immediately i.e before server is finished with undeploying
# more like a safe side one, may not be required also
java.lang.Thread.sleep(60000)
print('Now deploying ' + appName)
deploy(appName, appPath, appTarget)
disconnect()
Tried to config smtp in application.conf
mail.smtp.host=smtp.sendgrid.net
mail.smtp.user=${SENDGRID_USERNAME}
mail.smtp.pass=${SENDGRID_PASSWORD}
And in the controller
MultiPartEmail email = new MultiPartEmail();
//... setting from,to,subject,content...
Mail.send(email); //using Play's util
But exception occurs, saying bad user credential when authenticating the smtp server.
One thing I notice is that, when push to heroku and start the app, it would warn:
WARNING: Cannot replace SENDGRID_USERNAME in configuration (mail.smtp.user=${SENDGRID_USERNAME})
WARNING: Cannot replace ENV_SENDGRID_PASSWORD in configuration (mail.smtp.pass=${SENDGRID_PASSWORD})
This may due to the precompile flag is on when deploy?? Here is my Procfile:
web: play run --http.port=$PORT --%prod
I've created a simple Play + SendGrid + Heroku example that works for me:
https://github.com/jamesward/playsendgrid
I'm not sure what is different between this example and your code. The only weird thing I noticed above is where it says ENV_SENDGRID_PASSWORD. Perhaps that environment variable name is wrong.