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.
- Open a new command prompt so we can install Python-based dependencies. The command prompt must be new after the install so that environment variables updated during the installation are loaded.
- Navigate to the folder you want to store your virtualenvs in. For example
cd C:\Code - Type
python -m venv ./server_virtualenvto create a virtual environment named `server_virtualenv in the current folder. - We'll want to use this virtual environment, so type
./server_virtualenv/Scripts/activate.batand 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.
-
If you installed Postgres on a separate server, one of the gotchas is that Postgres requires host-based authentication (in addition to any required firewall configuration on each machine). If you want to connect the server with Postgres to the web server, you need to have allowed the Postgres server to connect in a text configuration file. You can set up this "host-based authentication" to allow the server this code is running on to connect to your database server. See their documentation for more details. This file can most easily be edited by navigating to
C:\Program Files\PostgreSQL\10\data\and right clicking onpg_hba.confand selectingEdit with Notepad++if you have installed Notepad++. -
Create your user account for this project. In the installation, you'll have created the root user account for managing all of the database. DO NOT USE THIS USER ACCOUNT IN THIS CODE. Instead, log into PGAdmin with that root user account and create a new user account - remember the username and password - you'll plug them into a configuration file later. You can create a new user account by right clicking on
Login/Group Rolesand selectingCreate.- On the "
Generaltab, create a username in theNamebox. We named iticefishin the initial install. - On the
Definitiontab, set a password. - On the
Privilegestab, changeCan login?toYes. Leave the rest at their defaults.
- On the "
-
Create a new database in PGAdmin. This is relatively straightforward. Name it whatever you like, but remember that name. To do this, right click on
Databasesin the tree and again, selectCreate.- On the
Generaltab, give it a name - we called iticefishdbin the initial install. Leave the Owner as the root user (namedpostgresby 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. - On the
Securitytab, click the plus sign in thePrivilegesheading. Select the new user you just created as theGrantee, check the box next toConnectthat pops into thePrivilegescolumn, but leaveWith Grant Optionunchecked, and leaveGrantoras your root user account. - Click
Saveto create the database.
- On the
-
Now connect to the new database by double clicking on it in the tree. We need to create a new
Schemaor tablespace, by right clicking on theSchemasportion of the tree and going to create.- Give the schema a name on the
Generaltab, again leaving postgres as the owner. We've named iticefish_backendin the initial install. - On the
Securitytab, again add a record and select your new user account as theGrantee. Give itALLprivileges by checking that box, but again, do not checkWith Grant Option* - On the
Default Privilegestab, 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.- On the
Tablessubtab, add a row, select your new user account as the Grantee, and again select theAlloption without selectingWith Grant Option. Then, uncheck theTruncateoption. Together, these will give the new user the ability to create, modify, and delete data - only within this schema. - On the
Sequencestab, again giveAllprivileges to your new user - no grant option - On both the
FunctionsandTypestabs, give the new user the only privilege available for each of those. Once again, do not select theWith Grant Optionboxes.
- On the
- Click Save to create the schema and assign the privileges.
- Give the schema a name on the
-
Now, go back to the properties for your new user account, and we'll set up some parameters. Switch to the
Parameterstab 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:
- Make a copy of the file
local_settings_template.pyin the same folder it's in and rename it tolocal_settings.py* - Edit that file with a text editor and fill in the values on each line. Each line has a Python comment, following the pound/hash sign that indicates what should be filled in there.
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
- Create user account for wowza - make it an admin (some things break without it)
- Give it full control permissions over the wowza install folder
- Set the wowza services to run as that new user
- log in as wowza and map drives Z, V, and H for it
- Open port 1935 in router to wowza
- Create application on wowza for video on demand. Enter a path, but it doesn't need to be valid. Edit that application's config file and set the directory to be the UNC path to the share. scheduled tasks Startup task for Perl/NCDC setup Setting up user account for scheduled tasks setting up moni
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_ctdThe 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 DSOn MOO1, there is a batch script that handles updates for the kiosk. The basic process is the following:
- Open a command prompt as an admin
- cd to
C:\Code - run
virtualenvs/server_virtualenv/scripts/activate - cd into
icefish_backend - run
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