<commit_before># INSTRUCTIONS WIP

# Debian Jesse (ex. Raspberry Pi Raspian)
```
apt install libffi-dev libreadline-dev libssl-dev libopus0

# Compile Python 3.5
wget *python 3.5+*
tar xzf *python*.tgz
cd *python*
./configure (--prefix=*blah*)
make -j(*numCPUs*)
make install

# Set up virtual env
cd ..
(*blah*/)pyvenv ./CrabBotEnv
cd CrabBotEnv
source bin/activate
pip3 install *discord.py git async branch*
pip3 install youtube-dl
git clone *CrabBot git*
cd CrabBot
python3 __main__.py (whichever token method) --use-libav
```

Rasbian alternately has ffmpeg in jesse-backports

GNU screen is handy for remote work. Run CrabBot in `screen -S CrabBotRun`, then `ctrl+a d`. `screen -R` to reattach.

# Extra Linux/Mac stuff

Use `pyvenv` to create virtual environments

## start-crabbot.sh

```
#!/bin/bash

CRABBOTENV=*CrabBotVEnvDir*
CRABBOTARGS="*either file or token args* *additional args, ex. --memes-path*"

cd $CRABBOTENV
source bin/activate  # Can remove this if not using a virtual env
cd CrabBot  # Can also remove this if not using a virtual env

# Create a new detached screen
screen -d -m -S CrabBotRun python3 __main__.py $CRABBOTARGS
echo "Use \`screen -R CrabBotRun\` to control CrabBot"

```

## crabbot.service (for systemd)

Put in `/etc/systemd/system`

```
[Unit]
Description=Start CrabBot at startup.

[Service]
Type=forking
User=*USERNAME*
ExecStart=*CrabBotDir*/start-crabbot.sh
ExecStop=screen -X -S CrabBotRun quit
WorkingDirectory=*CrabBotDir*

[Install]
WantedBy=multi-user.target
```

Then `systemctl enable crabbot.service` and `systemctl start crabbot.service`

Reference: [Autostart Process Gnu Screen Systemd/](http://www.linuxveda.com/2014/04/28/autostart-process-gnu-screen-systemd/)

## Read the log file live

`tail -f crabbot.log`
<commit_msg>Attempt to fix the example service<commit_after># INSTRUCTIONS WIP

# Debian Jesse (ex. Raspberry Pi Raspian)
```
apt install libffi-dev libreadline-dev libssl-dev libopus0

# Compile Python 3.5
wget *python 3.5+*
tar xzf *python*.tgz
cd *python*
./configure (--prefix=*blah*)
make -j(*numCPUs*)
make install

# Set up virtual env
cd ..
(*blah*/)pyvenv ./CrabBotEnv
cd CrabBotEnv
source bin/activate
pip3 install *discord.py git async branch*
pip3 install youtube-dl
git clone *CrabBot git*
cd CrabBot
python3 __main__.py (whichever token method) --use-libav
```

Rasbian alternately has ffmpeg in jesse-backports

GNU screen is handy for remote work. Run CrabBot in `screen -S CrabBotRun`, then `ctrl+a d`. `screen -R` to reattach.

# Extra Linux/Mac stuff

Use `pyvenv` to create virtual environments

## start-crabbot.sh

```
#!/bin/bash

CRABBOTENV=*CrabBotVEnvDir*
CRABBOTARGS="*either file or token args* *additional args, ex. --memes-path*"

cd $CRABBOTENV
source bin/activate  # Can remove this if not using a virtual env
cd CrabBot  # Can also remove this if not using a virtual env

# Create a new detached screen
screen -d -m -S CrabBotRun python3 __main__.py $CRABBOTARGS
echo "Use \`screen -R CrabBotRun\` to control CrabBot"

```

## crabbot.service (for systemd)

Put in `/etc/systemd/system`

```
[Unit]
Description=Start CrabBot at startup.

[Service]
Type=forking
User=*USERNAME*
ExecStart=*CrabBotDir*/start-crabbot.sh
ExecStop=screen -X -S CrabBotRun quit  # KillSignal=SIGINT instead? Phantom login bug currently
WorkingDirectory=*CrabBotDir*

[Install]
WantedBy=network-online.target
```

Then `systemctl enable crabbot.service` and `systemctl start crabbot.service`

Reference: [Autostart Process Gnu Screen Systemd/](http://www.linuxveda.com/2014/04/28/autostart-process-gnu-screen-systemd/)

## Read the log file live

`tail -f crabbot.log`

{'fraction_non_alphanumeric': 0.11263359824609483, 'fraction_numerical': 0.009317621266100301, 'mean_word_length': 4.581039755351682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2160608', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1297, 'n_words': 415}