{"id":13697593,"url":"https://github.com/kabirbaidhya/pglistend","last_synced_at":"2025-03-23T01:32:34.026Z","repository":{"id":57322701,"uuid":"62128917","full_name":"kabirbaidhya/pglistend","owner":"kabirbaidhya","description":"pglistend - A lightweight PostgreSQL LISTEN Daemon using Node.js/Systemd","archived":false,"fork":false,"pushed_at":"2017-03-29T18:32:15.000Z","size":324,"stargazers_count":29,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-14T17:16:55.738Z","etag":null,"topics":["daemon","database","listen","nodejs","postgres"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kabirbaidhya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-28T09:38:14.000Z","updated_at":"2025-01-04T04:16:26.000Z","dependencies_parsed_at":"2022-09-10T16:51:52.352Z","dependency_job_id":null,"html_url":"https://github.com/kabirbaidhya/pglistend","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kabirbaidhya%2Fpglistend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kabirbaidhya%2Fpglistend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kabirbaidhya%2Fpglistend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kabirbaidhya%2Fpglistend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kabirbaidhya","download_url":"https://codeload.github.com/kabirbaidhya/pglistend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245044143,"owners_count":20551884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["daemon","database","listen","nodejs","postgres"],"created_at":"2024-08-02T18:01:00.549Z","updated_at":"2025-03-23T01:32:33.751Z","avatar_url":"https://github.com/kabirbaidhya.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","Compiled list","Utilities"],"sub_categories":["Uncategorized","plv8:"],"readme":"# pglistend\n[![npm version](https://img.shields.io/npm/v/pglistend.svg?style=flat-square)](https://www.npmjs.com/package/pglistend) [![npm downloads](https://img.shields.io/npm/dt/pglistend.svg?style=flat-square)](https://www.npmjs.com/package/pglistend) [![Code Climate](https://img.shields.io/codeclimate/github/kabirbaidhya/pglistend.svg?style=flat-square)](https://codeclimate.com/github/kabirbaidhya/pglistend)\n\nA lightweight Postgres LISTEN Daemon built on top of [node](https://nodejs.org/en/), [node-postgres](https://github.com/brianc/node-postgres) and [systemd](https://wiki.debian.org/systemd).\n\nIt's a very simple yet generic daemon application that could be used in any project that makes use of Postgres' `LISTEN`/`NOTIFY` feature.\n\nIt runs as a background process that does `LISTEN` on the configured channels on a database and allows to perform custom actions on receiving [`NOTIFY`](https://www.postgresql.org/docs/9.1/static/sql-notify.html) signals on those channels.\n\nCheck this [simple tutorial](https://github.com/kabirbaidhya/pglistend/wiki/Tutorial:-Basics) to get started with it.\n\n## Installation\n\nFirstly, install the npm package globally. This will make `pglisten` CLI tool available on your system.\n```bash\n$ npm install -g pglistend\n```\n\nNow setup the daemon using this command.\n\n```bash\n$ sudo pglisten setup-daemon\n```\nOr, alternatively you can `curl` the script and run it on the fly.\n```bash\n$ curl https://raw.githubusercontent.com/kabirbaidhya/pglistend/master/setup/setup.py | sudo python\n```\n\nWhen it's done, edit your [configuration](https://github.com/kabirbaidhya/pglistend/wiki/Configuration). And finally start the service using\n```bash\n$ sudo systemctl start pglistend\n```\n\n## Usage\n### Managing the daemon\nYou can use `systemd` commands to manage `pglistend`.\n```bash\n# Start the service\n$ systemctl start pglistend\n\n# Stop the service\n$ systemctl stop pglistend\n\n# Check service status\n$ systemctl status pglistend\n\n# Enable the service (This will start the service on bootup)\n$ systemctl enable pglistend\n\n# Disable the service (Disable the service to not start on bootup)\n$ systemctl disable pglistend\n```\n\nFor more information about `systemd` check [this](https://wiki.debian.org/systemd#Managing_services_with_systemd)\n\n### Logs\nAll logs are written to `syslog`.\nSo, you can make use of `journalctl` here\n```bash\n$ journalctl -u pglistend\n$ journalctl -f -u pglistend\n```\n\nOr, you can simply `tail` the logs like this:\n```bash\n$ tail /var/log/syslog | grep pglistend\n$ tail -f /var/log/syslog | grep pglistend\n```\nCheck [this](https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs) to read more about journalctl.\n\n\n## Tutorials\n1. [Getting Started](https://github.com/kabirbaidhya/pglistend/wiki/Tutorial:-Basics)\n2. [Performing custom actions](https://github.com/kabirbaidhya/pglistend/wiki/Tutorial:-Custom-actions)\n\n## Testing\n1. Clone repository: `git clone git@github.com:kabirbaidhya/pglistend.git`\n2. Install dependencies: `npm install`\n3. Install other required packages:\n    - `pycodestyle`: `pip install pycodestyle` or `pip install --upgrade pycodestyle` [[Reference](https://github.com/PyCQA/pycodestyle)]\n    - `pylint`: `sudo apt-get install pylint` [[Reference](https://www.pylint.org/#install)]\n4. Copy configuration file `config.yml.sample` and rename to `.pglistend.yml` in root directory. Update database credentials, channels and location of scripts.\n5. To prepare a script, copy `listener.js.sample` and save it as `listener.js`, or anything you wish, to any location(recommended to save outside project directory). Update the preferred channels and instructions in the script. Also, update the location of script in `.pglistend.yml`.\n6. From terminal in root directory, run: `npm start`. You can see the logs in terminal as the channels hit the queries when the `notify` operation is called on.\n\n## TODOs\n* Delegate CPU-intensive tasks (mostly queries) to separate thread or message queue most likely. [Here's why](http://stackoverflow.com/questions/3491811/node-js-and-cpu-intensive-requests/3536183#answer-3491931)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkabirbaidhya%2Fpglistend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkabirbaidhya%2Fpglistend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkabirbaidhya%2Fpglistend/lists"}