https://github.com/mr-dxdy/pg_notifier
Process notifies about notifications from postgresql
https://github.com/mr-dxdy/pg_notifier
pg ruby
Last synced: about 1 year ago
JSON representation
Process notifies about notifications from postgresql
- Host: GitHub
- URL: https://github.com/mr-dxdy/pg_notifier
- Owner: mr-dxdy
- License: mit
- Created: 2017-05-22T13:19:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-25T07:59:40.000Z (about 9 years ago)
- Last Synced: 2025-06-08T21:35:49.052Z (about 1 year ago)
- Topics: pg, ruby
- Language: Ruby
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PgNotifier
Process notifies about postgresql notifications.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'pg_notifier'
```
## Quickstart
Create notifiers.rb:
``` ruby
require 'pg_notifier'
module PgNotifier
configure do |notifier|
notifier.logger = Logger.new('/var/log/pg_notifier.log')
notifier.db_config = {
host: 'localhost',
port: 5432,
dbname: database_production,
user: 'postgres',
password: 'postgres'
}
end
notify 'created_user' do |channel, pid, payload|
puts "#{channel} #{pid} #{payload}"
end
end
```
Run it with the pg_notifier executable:
``` bash
$ pg_notifier notifiers.rb
```
If you need to load your entire environment for your jobs, simply add:
``` bash
require 'pg_notifier'
require './config/boot'
require './config/environment'
```