diff --git a/README.md b/README.md index 26d98e1..862988a 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ ``` git clone https://github.com/making/cf-grafana.git cd cf-grafana -wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.3.2.linux-x64.tar.gz -tar -zxvf grafana-4.3.2.linux-x64.tar.gz -mv grafana-4.3.2 grafana +wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.2.linux-amd64.tar.gz +tar -zxvf grafana-5.3.2.linux-amd64.tar.gz +mv grafana-5.3.2.linux-amd64 # In case of Pivotal Web Services cf create-service cleardb spark grafana-db # In case of Pivotal Cloud Foundry @@ -24,7 +24,6 @@ Go to https://my-grafana.cfapps.io > If you don't need to persist dashboards and users, you can use default sqlite3 as follows. This is much better experience than free ClearDB though everything in the instance will disappear when you restart the application. > > ``` -> sed -i -e 's|^http_port = 3000$|http_port = 8080|' ./conf/defaults.ini > cf push my-grafana -b binary_buildpack -c './bin/grafana-server web' -m 64m > ``` diff --git a/conf/custom.ini b/conf/custom.ini new file mode 100644 index 0000000..e1ff5dc --- /dev/null +++ b/conf/custom.ini @@ -0,0 +1,10 @@ +#################################### Server ############################## +[server] +# The http port to use +http_port = 8080 + +# The public facing domain name used to access grafana from a browser +# domain = + +# The full public facing url +# root_url = diff --git a/run.sh b/run.sh index dbef69f..93e15a6 100755 --- a/run.sh +++ b/run.sh @@ -12,24 +12,23 @@ fi echo "Detected $SERVICE" -MYSQL_URI=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.uri'` -MYSQL_HOSTNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.hostname'` -MYSQL_PASSWORD=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.password'` -MYSQL_PORT=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.port'` -MYSQL_USERNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.username'` -MYSQL_DATABASE=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.name'` +# MYSQL_HOSTNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.hostname'` +# MYSQL_PASSWORD=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.password'` +# MYSQL_PORT=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.port'` +# MYSQL_USERNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.username'` +# MYSQL_DATABASE=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.name'` -SESSION_CONFIG="$MYSQL_USERNAME:$MYSQL_PASSWORD@tcp($MYSQL_HOSTNAME:$MYSQL_PORT)/$MYSQL_DATABASE" +# SESSION_CONFIG="$MYSQL_USERNAME:$MYSQL_PASSWORD@tcp($MYSQL_HOSTNAME:$MYSQL_PORT)/$MYSQL_DATABASE" cd $GRAFANA_DIR -sed -i -e 's|^url =$|url = '$MYSQL_URI'|' ./conf/defaults.ini -sed -i -e 's|^type = sqlite3$|type = mysql|' ./conf/defaults.ini -sed -i -e 's|^http_port = 3000$|http_port = 8080|' ./conf/defaults.ini -sed -i -e 's|mode = console file|mode = console|' ./conf/defaults.ini +export GF_DATABASE_TYPE=mysql +# drop ?reconnect=true from connection string because Grafana doesn't handle it properly +DATABASE_URL=${DATABASE_URL/?reconnect=true} +export GF_DATABASE_URL=${DATABASE_URL/mysql2/mysql} # replace "mysql2://..." which Grafana doesn't understand in $DATABASE_URL with "mysql://..." # sed -i -e 's|max_idle_conn =|max_idle_conn = 1|' ./conf/defaults.ini # sed -i -e 's|max_open_conn =|max_open_conn = 3|' ./conf/defaults.ini # sed -i -e 's|provider = file|provider = mysql|' ./conf/defaults.ini # sed -i -e 's|provider_config = sessions|provider_config = '$SESSION_CONFIG'|' ./conf/defaults.ini echo "Start Grafana" -./bin/grafana-server web & \ No newline at end of file +./bin/grafana-server web &