1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-22 11:33:34 +03:00
guide/INSTALL.md

115 lines
3.0 KiB
Markdown
Raw Permalink Normal View History

# Points to keep in mind
2018-12-10 01:02:03 +03:00
The `back/state/` directory contains the database. You can download the current database of [guide.aelve.com](http://guide.aelve.com) by doing this:
2018-12-10 01:02:03 +03:00
$ make back/db
2018-12-10 01:02:03 +03:00
The `back/config.json` file contains the config (it will be created at the first start):
2016-03-23 01:53:38 +03:00
* `admin-password` is the password for the admin panel (at `/admin`). Leave it empty if you don't want any password.
* `google-token` lets you set the Google site verification token. Leave it empty if you don't want Google verification.
* `base-url` is the URL of the server (which should contain `http://` or `https://`). It's used for feed generation.
2016-08-25 17:05:29 +03:00
* `discuss-url` adds a “discuss this site” link under the header. You can leave it as `null`.
2016-03-09 21:44:59 +03:00
# How to install locally
First install `libpq`. Then do:
2018-09-24 00:57:44 +03:00
2018-12-10 01:02:03 +03:00
$ make back
$ make back/run
2016-03-09 21:44:59 +03:00
2019-08-11 16:01:37 +03:00
And go to <http://localhost:8080>. The admin page is available at <http://localhost:8080/admin>.
2016-03-09 21:44:59 +03:00
# How to install on a server
I'm going to use Digitalocean and Ubuntu, but you can use anything else.
2016-08-25 17:05:29 +03:00
Create a droplet with Ubuntu. Install Stack (this command will import a GPG key, add Stack's repository, and run `apt-get`):
2016-03-09 21:44:59 +03:00
2016-08-25 17:05:29 +03:00
$ curl -sSL https://get.haskellstack.org/ | sh
2016-03-09 21:44:59 +03:00
Install `libpq`.
2018-09-24 00:57:44 +03:00
2016-03-09 21:44:59 +03:00
Clone and build `guide`:
$ git clone https://github.com/aelve/guide
$ cd guide
2018-12-10 01:02:03 +03:00
$ make back
$ stack install --fast
2016-03-09 21:44:59 +03:00
Make a new subdomain in Apache. For me, it means writing this to `/etc/apache2/sites-available/guide.conf`:
~~~
<VirtualHost *:80>
ServerName guide.aelve.com
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
</VirtualHost>
~~~
Enable the `remoteip` module (this is needed so that the `/admin` page would display actual IPs instead of `127.0.0.1`):
$ a2enmod remoteip
2016-03-09 21:44:59 +03:00
Enable the site:
$ a2ensite guide
$ service apache2 reload
Create a daemon. This goes to `/etc/init/guide.conf` (the path is going to be something other than `/root/guide` for you):
~~~
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
chdir /root/guide
env LC_ALL=en_US.UTF-8
2016-08-25 17:05:29 +03:00
exec /root/.local/bin/guide
2016-03-09 21:44:59 +03:00
~~~
2016-03-19 21:36:21 +03:00
Start the daemon:
2016-03-09 21:44:59 +03:00
$ service guide start
2016-03-11 18:40:34 +03:00
## Database
You can set automatic backups of the database to your own repository.
2016-03-11 18:40:34 +03:00
Create `.gitignore` in the `state/` folder:
~~~
2016-05-21 16:53:40 +03:00
Archive/
2016-03-11 18:40:34 +03:00
events*
*.lock
2019-06-19 16:54:47 +03:00
*.log
2016-03-11 18:40:34 +03:00
~~~
Create a repository locally and remotely. If you're using Github, you can avoid having to enter passwords by generate an access token and using it as username when adding a remote:
$ git remote add origin https://<token>@github.com/aelve/guide-database.git
Next, create `upload.sh`:
~~~
cd /root/guide/state
2019-06-19 16:54:00 +03:00
rm -f *.gz
gzip -k -f *.log
2016-03-11 19:14:29 +03:00
git add -A
2016-03-11 18:40:34 +03:00
GIT_COMMITTER_NAME='auto' GIT_COMMITTER_EMAIL='' git commit --author="auto <>" -m "`date`"
git push
~~~
2016-03-12 00:09:52 +03:00
$ chmod +x upload.sh
2019-06-19 16:54:47 +03:00
Finally, make a cron job that would try to upload new data every 10m (though the actual checkpoints are only created once per six hours):
2016-03-11 18:40:34 +03:00
$ crontab -e
~~~
2016-03-12 00:09:52 +03:00
*/10 * * * * /bin/bash /root/guide/upload.sh
2016-03-11 18:40:34 +03:00
~~~