<commit_before># starting

```bash
# start datomic db elsewhere
lein with-profile lp repl
```

```clojure
(chat.server.db/init!) ; first time only

(chat.server.seed/seed!) ; optional

(chat.server.handler/start-server! 5555)
(chat.server.sync/start-router!)
```

# running tests

`lein with-profile test,lp quickie "chat.*"`


# deploying

`./deploy.sh`

then ssh to chat.leanpixel.com and

`sudo supervisorctl restart chat`


# production notes

nrepl is started on port 3081.  To connect, forward the port when ssh'ing in, e.g.

`ssh -L 3081:localhost:3081 chat.leanpixel.com`

then you can `lein repl :connect 3081` locally.

App log files are at `/www/deploys/chat/chat-server.log` and `/www/deploys/chat/chat-server.err.log` (stdout & stderr, respectively)

Datomic logs are at `/home/james/datomic.log` and `/home/james/datomic.err.log` (bad location, I should update this)

Nginx logs are at `/var/log/nginx/chat.access.log` and `/var/log/nginx/chat.error.log`


# initial remote setup

setting up a production instance of chat looks as follows:

(assuming a server has been deployed, users & ssh keys added for us, root login disabled, users added to admin group, etc)

## install required programs:<commit_msg>add readme instructions for setting up ufw & fail2ban<commit_after># starting

```bash
# start datomic db elsewhere
lein with-profile lp repl
```

```clojure
(chat.server.db/init!) ; first time only

(chat.server.seed/seed!) ; optional

(chat.server.handler/start-server! 5555)
(chat.server.sync/start-router!)
```

# running tests

`lein with-profile test,lp quickie "chat.*"`


# deploying

`./deploy.sh`

then ssh to chat.leanpixel.com and

`sudo supervisorctl restart chat`


# production notes

nrepl is started on port 3081.  To connect, forward the port when ssh'ing in, e.g.

`ssh -L 3081:localhost:3081 chat.leanpixel.com`

then you can `lein repl :connect 3081` locally.

App log files are at `/www/deploys/chat/chat-server.log` and `/www/deploys/chat/chat-server.err.log` (stdout & stderr, respectively)

Datomic logs are at `/home/james/datomic.log` and `/home/james/datomic.err.log` (bad location, I should update this)

Nginx logs are at `/var/log/nginx/chat.access.log` and `/var/log/nginx/chat.error.log`


# initial remote setup

setting up a production instance of chat looks as follows:

(assuming a server has been deployed, users & ssh keys added for us, root login disabled, users added to admin group, etc)

## Security stuff

Disable root login and disallow cleartext logins over ssh

```
sudo apt-get install fail2ban
sudo service fail2ban start
```

```
sudo ufw allow ssh
sudo ufw allow www
sudo ufw allow 443
sudo ufw enable
```

## install required programs:
{'fraction_non_alphanumeric': 0.1152567417805689, 'fraction_numerical': 0.01699298115995567, 'mean_word_length': 4.177820267686425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5117510', 'n_tokens_mistral': 972, 'n_tokens_neox': 891, 'n_words': 312}