The Webhook Server runs several workers and web servers that are used in conjuction with the webhook-cms and webhook tools to generate static sites.
The workers handle things such as: Generating static sites on demand, uploading static sites to cloud storage, inviting users to work on sites, backing up data periodically, etc.
The web server handles things such as: Uploading images, searching using elastic search, and uploading sites to the workers.
We welcome contributions to this repo, but please be cognisant that this code runs on thousands of websites. Therefor we're pretty strict about what we accept.
Please consider the following before submitting your pull request:
- Is the code backwards compatible with previous versions of the server?
- Is the code documented, properly explained and follow the naming patterns of the current code?
- Does it add generic abilities that are useful to most projects, not just your own?
- You are contributing your code under the MIT license this code is provided with.
Goes without saying you'll need to have Node, Grunt and Webhook installed to work on this repo.
You will also need a local daemon of Beanstalk and Memacached running if you wish to work on the workers.
In order to run the webhoook web server you can:
- Clone this repo somewhere locally.
cd webhook-server-open
- Configure the Gruntfile.js appropriately
- Run
grunt startServer
. - Then when using the
wh
commands simply supply the --server option with your local ip address
In order to run the webhook workers locally you will need to:
- Have beanstalkd running
- Have memcached running
- Clone this repo somewhere locally
cd webhook-server-open
- Configure the Gruntfile.js appropriately
- Run the command delagator
grunt commandDelegator
- Run the worker you want e.g.
grunt buildWorker
- Then when using the
wh
commands simply supply the --server option with your local ip address
Please do the following when submitting a pull request:
- Please create a corresponding issue for the pull request.
- Please name the issue as either a feature addition or a bug fix.
- Please reference an issues in your pull requests.
Here is a description of the various files that are in the server repo, and what their purpose is:
- The main gruntfile.
- Contains the configuration options for the self-hosting setup
- Contains the cron job used to backup data from firebase
- Should be set to run at least once a day
- Contains the utilities used to extract the backup of a specific site from the nightly backups
- The main build worker, handles building sites when signaled and uploading them to cloud storage
- Downloads sites from google cloud storage, extracts local copies to a build folder
- Main API Library for interacting with cloud storage through node.
- Used by almost every other worker/server, very important.
- Handles delegating commands from firebase to beanstalk.
- Uses memcached to avoid duplicate jobs
- Worker that creates and initializes new sites.
- Creates buckets in cloud storage, creates access key used to access buckets in firebase.
- Utility to extract google service account SSH key for self-hosting.
- A library used to get/set data from firebase through HTTP rather than Websockets
- Useful for situations where a long running websocket is undesirable.
- The invite worker, handles sending invite emails to users who have been invited to a site
- The jobQueue base file, used by all workers, handles reserving jobs from Beanstalk
- Uses memcached to lock jobs while processing
- The main webhook web server
- Handles uploading files from wh push to workers
- Handles uploading files/images from the CMS
- Handles search ruquests against elastic