I Decided to remove static asset compression from actual code to make runtime faster and moved it to package.json script which only builds application once on installation.\nAfter this commit, after every update that changed static/application.js, you also need to run npm run-script build after git pull
3.6 KiB
Short instructions
- Install node
- Build with
npm run-script build
- Rename
example.config.js
toconfig.js
(Defaults are enough) - (Optional) Change document storage system (guide)
- Run with
npm start
ornode .
Full installation instructions
NOTE: This guide assumes you're on a Linux server, like Debian 10 or Ubuntu 20.04.
If you're using windows, you will have to improvise a bit with Autorestarts.
Table of Contents
Set up node
Hastebin server runs on the JavaScript runtime called node, so you need to download it first:
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs
If method above didn't work use this guide.
For Windows enviroments, you can download and install node from its website.
Node should also automatically install npm which will help us install dependencies. You can verify your installations, with following commands
node -v
npm -v
Install dependencies
Hastebin makes use of several node packages, you can install them and configure with:
npm run-script build
Edit configuration
Haste can already work "out-of-the-box" with no config changes - useful for environments like Heroku or Dokku.
You can use HOST
and PORT
environment variables for host and port specification to override config values.
However, there is an example configuration file available for you to copy:
cp example.config.js config.js
By default storage system stores haste documents as hashed files in ./data
directory.
Rest of provided defaults are enough to run the server, however, example config contains comments about what each value does and you can adjust the options to your likings.
Guide for all supported storage systems.
Guide for all supported key generators.
Run the server
You should now be able to start the server with the following command:
npm run-script start
To stop server the server, hit Ctrl + C
Further steps
Once you're good to go and server is running you probably want to keep it alive 24/7 - to achieve that you can choose from variety of things like: pm2, systemd, screen, etc.
Here, I will cover a basic guide to the PM2 - a program which will make sure your server is running 24/7 with autorestarts.
Download it with npm:
sudo npm install pm2 -g
Now assign Hastebin server to pm2's daemon:
pm2 start "npm start" --name=haste
To ensure haste server will automatically start after server reboot you need to retrieve startup script and execute it.
Example:
$ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u zneix --hp /home/zneix
Now, just copy-paste the last line into your terminal and you should be done.
PM2 Commands:
-
pm2 list
: displays list of all pm2 processes -
pm2 logs haste
: displays server logs -
pm2 restart haste
: restarts Hastebin server (you will need to do that after config changes, etc.) -
pm2 stop haste
: stops Hastebin server -
pm2 start haste
: starts Hastebin server if it was stopped manually before