2016-03-16 23:47:59 +03:00
# Points to keep in mind
The `state/` directory contains the database. You can download the current database of [guide.aelve.com ](http://guide.aelve.com ) by doing this:
$ git clone https://github.com/aelve/guide-database
$ mv guide-database state
2016-03-23 01:53:38 +03:00
The `config.json` file contains the config (it will be created at the 1st start). There are 3 settings so far:
2016-03-22 01:17:53 +03:00
* `tracking-enabled` enables tracking. If you do enable it, don't forget to replace the contents of `static/tracking.md` with your own tracking script.
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.
2016-03-22 01:17:53 +03:00
* `base-url` is the URL of the server (which should contain `http://` or `https://` ). It's used for feed generation.
2016-03-16 23:47:59 +03:00
2016-03-09 21:44:59 +03:00
# How to install locally
$ cabal install --only-dependencies
$ cabal build
$ dist/build/guide/guide
2016-03-14 22:13:57 +03:00
And go to < http: / / localhost:8080 > . The status page is available at < http: / / localhost:5050 > .
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.
Create a droplet with Ubuntu. Install GHC:
$ add-apt-repository ppa:hvr/ghc
$ apt-get update
$ apt-get install ghc-7.10.3 cabal-install-1.22
Add cabal-install, GHC, and the cabal dir to `PATH` by adding
/opt/cabal/1.22/bin:/opt/ghc/7.10.3/bin:$HOME/.cabal/bin
to `PATH` in `~/.bashrc` and then doing `source ~/.bashrc` .
Clone and build `guide` :
$ git clone https://github.com/aelve/guide
$ cd guide
$ cabal update
$ cabal install --dependencies-only
$ cabal build
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 >
~~~
2016-03-14 22:13:57 +03:00
If you want the status page to be available as well, write:
~~~
< VirtualHost * :80 >
ServerName guide.aelve.com
ProxyPreserveHost On
ProxyPass /status/ http://0.0.0.0:5050/
ProxyPassReverse /status/ http://0.0.0.0:5050/
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
< / VirtualHost >
~~~
(Note that it will only be available at `/status/` , not `/status` .)
2016-04-08 23:28:54 +03:00
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
exec dist/build/guide/guide
~~~
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
2016-03-16 23:47:59 +03:00
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:
~~~
events*
*.lock
~~~
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
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
2016-03-11 18:40:34 +03:00
Finally, make a cron job that would try to upload new data every 10m (tho the actual checkpoints are only created once per hour):
$ 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
~~~