Note that the home for all of the code related to this project is in a B-195-M Organization on BitBucket. This code base is modular and contains subcomponents, some of which will have their own installation steps. The installers for this code base will handle most of it automatically, but will link you to installation documents in those repositories when appropriate.
As an introduction, all of the items in this installation are targeted toward Windows, but everything is developed to be cross-platform in the event that you should desire running on a Unix-based server. You should start with a full copy (clone) of this repository in a folder on the computer you want to serve it from.
This code base relies heavily on Python, so the first step is to download and install Python. This code is designed to work with Python 3.5 and above, with the main MOO server running Python 3.6.3 as of this writing. Your best bet is to try the latest version, then try 3.6.3 if the latest version doesn't work.
You can download Python installers from the Python.org website. While it doesn't matter for this project, the 64-bit version is the recommended distribution.
In order to better isolate the python packages we use, we'll make what's called a virtual environment - this allows different versions of Python packages to coexist for different projects on the same machine. It also allows us to control package installation without admin privileges. To set this up, open a command prompt, and navigate to where you want to keep the virtual environment. I recommend something like the following:
C:
|- Windows
|- Program Files
|- ...
|- Code
|- virtualenvs
|- server_virtualenv
|- icefish_backend
In the above tree, you have a Code folder on the C drive that stores code
for the project and has a separate folder for any virtual environments you
create. In that example, it has a virtual environment named server_virtualenv
.
Each package of code lives in its own folder in the main Code folder.
We'll use the name server_virtualenv
for our environment here, though
you can choose another name if you prefer.
cd C:\Code
python -m venv ./server_virtualenv
to create a virtual
environment named `server_virtualenv in the current folder../server_virtualenv/Scripts/activate.bat
and hit enter to run it.
That command makes the Python interpreter in the virtual environment
our default for this command line session.More documentation on venv can be found here if needed.
After setting up the virtual environment, we need to install packages. In that command prompt, navigate to the directory that this code is stored, the same folder this README file is located inside of, and type:
python -m pip install -r requirements.txt
That command will download and install all the necessary code for this project to run.
PostgreSQL is the intended database for this codebase. Though the project uses Django, which allows for any SQL-based database to be the backend, this code has only been tested with PostgreSQL and SQLite, and SQLite should not be used in production environments.
Download and install the latest 64-bit version of PostgreSQL for Windows. Most any version of the database should work, but we tested against 10.0, so using that version or newer is safest. You should be able to accept the defaults while installing, making sure to take note of the username and password you create during the installation.
Postgres requires a fair amount of setup. Fortunately, this code will do a lot of it (filling out the empty database with required tables), but you will still need to do the following. Everything besides the first step below can be done relatively easily in PGAdmin, an application that installs alongside PostgreSQL and can be used for administrative tasks. If you prefer, you can also use command line utilities, which are often referenced in documentation.
C:\Program Files\PostgreSQL\10\data\
and right clicking on pg_hba.conf
and selecting Edit with Notepad++
if
you have installed Notepad++.Login/Group Roles
and selecting Create
.
General
tab, create a username in the Name
box. We named it icefish
in the initial install.Definition
tab, set a password.Privileges
tab, change Can login?
to Yes
. Leave the rest
at their defaults.Databases
in the tree and again, select Create
.
General
tab, give it a name - we called it icefishdb
in
the initial install. Leave the Owner as the root user
(named postgres
by default). We'll give the new user account the ability
to operate the database below, but we'll leave ownership with a user
that's unconnected to the web server so that in the event of a web
security issue, the data is safer.Security
tab, click the plus sign in the Privileges
heading.
Select the new user you just created as the Grantee
, check the box
next to Connect
that pops into the Privileges
column, but leave
With Grant Option
unchecked, and leave Grantor
as your root user
account.Save
to create the database.Schema
or tablespace, by right clicking
on the Schemas
portion of the tree and going to create.
General
tab, again leaving postgres
as the owner. We've named it icefish_backend
in the initial install.Security
tab, again add a record and select your new user
account as the Grantee
. Give it ALL
privileges by checking that box,
but again, do not check With Grant Option
*Default Privileges
tab, we'll configure the settings for
new tables that will be created by our application using the new user
account. This is where we finally give that account the ability to do
things.
Tables
subtab, add a row, select your new user account
as the Grantee, and again select the All
option without selecting
With Grant Option
. Then, uncheck the Truncate
option.
Together, these will give the new user the ability to create, modify,
and delete data - only within this schema.Sequences
tab, again give All
privileges to your new
user - no grant optionFunctions
and Types
tabs, give the new user
the only privilege available for each of those. Once again, do not
select the With Grant Option
boxes.Now, go back to the properties for your new user account, and we'll
set up some parameters. Switch to the Parameters
tab and we'll add
three new rows:
+-------------------------------+----------------+---------------+
| Name | Value | Database |
+-------------------------------+----------------+---------------+
| client_encoding | UTF8 | icefishdb |
+-------------------------------+----------------+---------------+
| default_transaction_isolation | read_committed | icefishdb |
+-------------------------------+----------------+---------------+
| timezone | UTC | icefishdb |
+-------------------------------+----------------+---------------+
Replace icefishdb with whatever you named your database.
Now that you have the core dependencies installed, it's time to fill in
the configuration, as it applies to your local environment. Most
configuration is already filled out in settings.py in the folder
subfolder icefish_backend
of the main icefish_backend
folder, but you should:
local_settings_template.py
in the same folder
it's in and rename it to local_settings.py
*Now that you've configured the local settings, you can have the application
set up the database. To do this, open a command prompt (if you don't
have the previous one open still) and activate the virtual environment
as you did previously. Then, navigate into the main folder icefish_backend
and run the command python manage.py migrate
- follow any prompts it
gives you. This action will create all of the data tables for the
application and do any additional setup.
FLAC is the audio codec we use to losslessly compress the audio files while they are at rest, in storage. To run the conversion, we'll use the flac executable. Download the latest zip replease for windows from: https://ftp.osuosl.org/pub/xiph/releases/flac/ (the original version of the site uses flac-1.3.2-win.zip Extract the zipfile somewhere it can live (such as the Code directory) and fill in the full path to the flac.exe executable in your copy of local_settings.py (if you have already begun filling that out)
For SoX, simply go to its website and download the latest zip version. Again, extract the zip file to somewhere it can remain, and configure the path to sox.exe in your local_settings.py
Fill in gunicorn and apache? Backup for Postgres? Django superuser? Configure CTD COM Port Set entry in hosts file for array Connect to Synology Secure Wowza - make it run as a named user instead of as local system
See setup information in seabird_ctd repository
Need to install packages in requirements.txt and plug in CTD to computer.
Requires an environment variable to be set, named SEABIRD_CTD_PORT that indicates which COM port the CTD is connected on (eg COM6).
To run the script to monitor for CTD data, after setup is complete, simply run
python manage.py monitor_ctd
The console window that runs this will remain in an infinite loop monitoring until the computer shuts down or it is closed.
If you installed RabbitMQ and configured it in the local_settings.py file, then you can send commands to the CTD while it's sampling. The results of the command will be printed in the console of the monitoring script you started in the previous command.
To send a command to the CTD while it's running, use;
python manage.py send_command_to_ctd {command}
For example, to get the status output printed in the data reader's console
python manage.py send_command_to_ctd DS
On MOO1, there is a batch script that handles updates for the kiosk. The basic process is the following:
C:\Code
virtualenvs/server_virtualenv/scripts/activate
icefish_backend
update.bat
This script pulls changesets from BitBucket, updates to the latest release, updates any requirements specified in requirements.txt, then restarts the MOOWaitress (kiosk) service. It does not restart the CTD service or the image upload service