From efb194d70a1560f436e328f35924df0be52e2431 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 16 Feb 2016 15:36:26 -0500 Subject: [PATCH] LP#1492793: teach Clark Kent to set the Pg app name Clark Kent can now also use the application_name setting in the relevant sections of opensrf.xml to set the Pg application name. To test: [1] Apply the patch, restarting opensrf.settings, and start Clark. [2] Run a report that will take at least a minute to finish. While it is running, query the pg_stat_activity table. There should be at least one row where the application_name column is set to 'Clark Kent (reports)'. [3] Note that since the master Clark process opens a database connection, checks whether there are any reports to run, then immediately closes the connection, it's unlikely that you'll catch a 'Clark Kent (state)' connection when querying pg_stat_activity. Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander --- Open-ILS/examples/opensrf.xml.example | 4 ++-- Open-ILS/src/reporter/clark-kent.pl | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 7b6484cbcb..87db4cc49a 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -159,7 +159,7 @@ vim:et:ts=4:sw=4: evergreen postgres postgres - open-ils.reporter + Clark Kent (reports) Pg @@ -168,7 +168,7 @@ vim:et:ts=4:sw=4: evergreen postgres postgres - open-ils.reporter-state + Clark Kent (state) diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index fabd2dbe0b..9fbf6029a7 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -67,6 +67,7 @@ if (!$data_db{db_name}) { } $data_db{db_user} = $sc->config_value( reporter => setup => database => 'user' ); $data_db{db_pw} = $sc->config_value( reporter => setup => database => 'pw' ); +$data_db{db_app} = $sc->config_value( reporter => setup => database => 'application_name' ); @@ -80,6 +81,8 @@ if (!$state_db{db_name}) { } $state_db{db_user} = $sc->config_value( reporter => setup => state_store => 'user' ) || $data_db{db_user}; $state_db{db_pw} = $sc->config_value( reporter => setup => state_store => 'pw' ) || $data_db{db_pw}; +$state_db{db_app} = $sc->config_value( reporter => setup => state_store => 'application_name' ) + || $data_db{db_app}; die "Unable to retrieve database connection information from the settings server" @@ -94,7 +97,9 @@ my $output_base = $sc->config_value( reporter => setup => files => 'output_ my $base_uri = $sc->config_value( reporter => setup => 'base_uri' ); my $state_dsn = "dbi:" . $state_db{db_driver} . ":dbname=" . $state_db{db_name} .';host=' . $state_db{db_host} . ';port=' . $state_db{db_port}; +$state_dsn .= ";application_name='$state_db{db_app}'" if $state_db{db_app}; my $data_dsn = "dbi:" . $data_db{db_driver} . ":dbname=" . $data_db{db_name} .';host=' . $data_db{db_host} . ';port=' . $data_db{db_port}; +$data_dsn .= ";application_name='$data_db{db_app}'" if $data_db{db_app}; my $count = $opt_count // $sc->config_value( reporter => setup => 'parallel' ) // -- 2.43.2