ds debug
This commit is contained in:
+67
-2
@@ -74,9 +74,34 @@
|
||||
<cfset request.GUEST_USR_ID=3/>
|
||||
|
||||
<!--- global settings --->
|
||||
<cfset request.DS=this.datasource/>
|
||||
|
||||
<cfset this.datasource = "dwh"/>
|
||||
<cfset this.defaultdatasource = this.datasource/>
|
||||
<cfset request.DS = "#this.datasource#">
|
||||
|
||||
<!--- <cfdump var=#GetApplicationSettings()#/> --->
|
||||
|
||||
<!--- <cfif !structKeyExists(GetApplicationSettings().datasources,"#this.datasource#")>
|
||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||
</cfif>
|
||||
|
||||
<!--- неуклюжий выверт для локальной отладки --->
|
||||
<cfif !structKeyExists(this.datasources,"billing-vc")>
|
||||
<cfset this.datasources["billing-vc"]=getDS("billing-vc","ds_billing_vc")/>
|
||||
</cfif>
|
||||
|
||||
<cfif !structKeyExists(this.datasources,"billing-s3")>
|
||||
<cfset this.datasources["billing-s3"]=getDS("billing-s3","ds_billing_s3")/>
|
||||
</cfif> --->
|
||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||
<cfset this.datasources["billing-vc"]=getDS("billing-vc","ds_billing_vc")/>
|
||||
<cfset this.datasources["billing-s3"]=getDS("billing-s3","ds_billing_s3")/>
|
||||
|
||||
<cfdump var=#this.datasources#/>
|
||||
|
||||
|
||||
<cfset request.RECORDS_PER_PAGE=500/>
|
||||
<cfset request.APP_VERSION="0.00.000"/>
|
||||
<cfset request.APP_VERSION="0.00.001"/>
|
||||
<cfset request.STAND=getStand()/>
|
||||
|
||||
<cflock scope="application" type="readonly" timeout=3>
|
||||
@@ -288,4 +313,44 @@
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction
|
||||
name="getDS"
|
||||
access="private"
|
||||
returntype="struct"
|
||||
output="true"
|
||||
hint="Configure data source from environment variables. Convention: data source name is an environment varialble prefix">
|
||||
|
||||
<cfargument name="dsname" type="string" required="true"/>
|
||||
<cfargument name="prefix" type="string" default=#dsname#/>
|
||||
|
||||
<cfset system = createObject("java", "java.lang.System")/>
|
||||
<cfset var ds={}/>
|
||||
|
||||
<cfloop list="class,connectionString,database,driver,dbdriver,host,port,type,url,username,password,bundleName,bundleVersion,connectionLimit,liveTimeout,validate" item="field"><!--- driver vs dbdriver --->
|
||||
<cfset var value=system.getEnv("#arguments.prefix#_#field#")/>
|
||||
<cfif isDefined("value") AND len(value)>
|
||||
<cfset structInsert(ds,field,value)/>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
<cfif structIsEmpty(ds)>
|
||||
<cfthrow type="application" message="Datasource not configured" detail="Datasource not defined in the environment. Expected prefix is #arguments.prefix#"/>
|
||||
</cfif>
|
||||
|
||||
<!--- test datasource (just to get exception if invalid) --->
|
||||
<cftry>
|
||||
<cfquery name="qTestDs" datasource=#ds#>
|
||||
select 1;
|
||||
</cfquery>
|
||||
|
||||
<cfcatch type="any">
|
||||
<!--- <cfdump var=#ds#/><cfabort/> --->
|
||||
<cfrethrow/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfreturn ds/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
</cfcomponent>
|
||||
@@ -171,5 +171,6 @@
|
||||
</table>
|
||||
</cfif> --->
|
||||
|
||||
<!--- <cfdump var=#this.datasources#/> --->
|
||||
|
||||
<layout:page section="footer"/>
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"ds_dwh_class": "org.postgresql.Driver",
|
||||
"ds_dwh_connectionString": "jdbc:postgresql://db-services.adl.nubes.ru:5432/dwh",
|
||||
"ds_dwh_username": "smishchuk",
|
||||
"ds_dwh_password": "encrypted:*******",
|
||||
"ds_dwh_connectionLimit": "5",
|
||||
|
||||
"ds_billing_s3_class": "org.postgresql.Driver",
|
||||
"ds_billing_s3_connectionString": "jdbc:postgresql://db-services.adl.nubes.ru:5432/billing",
|
||||
"ds_billing_s3_username": "s3billing",
|
||||
"ds_billing_s3_password": "encrypted:*******",
|
||||
"ds_billing_s3_connectionLimit": "5",
|
||||
|
||||
"ds_billing_vc_class": "org.postgresql.Driver",
|
||||
"ds_billing_vc_connectionString": "jdbc:postgresql://db-services.adl.nubes.ru:5432/billing",
|
||||
"ds_billing_vc_username": "vc_billing",
|
||||
"ds_billing_vc_password": "encrypted:*******",
|
||||
"ds_billing_vc_connectionLimit": "5"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
REM set Windows env
|
||||
setx ds_dwh_class org.postgresql.Driver /M
|
||||
setx ds_dwh_connectionString jdbc:postgresql://db-services.adl.nubes.ru:5432/dwh /M
|
||||
setx ds_dwh_username smishchuk /M
|
||||
setx ds_dwh_password encrypted:******* /M
|
||||
setx ds_dwh_connectionLimit 5 /M
|
||||
|
||||
setx ds_billing_s3_class org.postgresql.Driver /M
|
||||
setx ds_billing_s3_connectionString jdbc:postgresql://db-services.adl.nubes.ru:5432/billing /M
|
||||
setx ds_billing_s3_username s3billing /M
|
||||
setx ds_billing_s3_password encrypted::******* /M
|
||||
setx ds_billing_s3_connectionLimit 5 /M
|
||||
|
||||
setx ds_billing_vc_class org.postgresql.Driver /M
|
||||
setx ds_billing_vc_connectionString jdbc:postgresql://db-services.adl.nubes.ru:5432/billing /M
|
||||
setx ds_billing_vc_username vc_billing /M
|
||||
setx ds_billing_vc_password encrypted::******* /M
|
||||
setx ds_billing_vc_connectionLimit 5 /M
|
||||
|
||||
pause
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<cftry>
|
||||
<cfdump var=#this.datasources#/>
|
||||
<cfdump var=#this.datasource#/>
|
||||
<cfdump var=#this.defaultdatasource#/>
|
||||
<cfdump var=#request.DS#/>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfoutput>#cfcatch#</cfoutput>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cftry>
|
||||
<cfquery name="qDwh" datasource="dwh">
|
||||
select 1;
|
||||
</cfquery>
|
||||
<cfdump var=#qDwh#/>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfoutput>#cfcatch#</cfoutput>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cftry>
|
||||
<cfquery name="qBillingVc" datasource="billing-vc">
|
||||
select 1;
|
||||
</cfquery>
|
||||
<cfdump var=#qBillingVc#/>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfoutput>#cfcatch#</cfoutput>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cftry>
|
||||
<cfquery name="qBillingS3" datasource="billing-s3">
|
||||
select 1;
|
||||
</cfquery>
|
||||
<cfdump var=#qBillingS3#/>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfoutput>#cfcatch#</cfoutput>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
Reference in New Issue
Block a user