Deploying cold
Deploying cold on a remote system requires manual setup. You will need the following software to successfully build and deploy.
- Deno >= 2.2.0 (for compiling COLD)
- Dataset >= 2.1.23
- CMTools >= 0.0.18 (for generating version.ts, about.md, CITATION.cff)
- Pandoc >= 3.1 (for compiling documentation)
- GNU Make
- Git
- Tmux highly recommended
- eLinks or Lynx recommended (to test form the console)
Deployment steps
My current recommendation is the following.
- Setup the directory to hold he web application if it doesn’t exist.
- Clone the repository, e.g. clone to
/Sites/coldand change into the repository directory - Run Deno tasks
setup(if the collections don’t exist) andbuildto build the binary for the cold service - Copy
cold.service-exampletocold.service, edit it and move to/etc/systemd/system/ - Copy
cold_api.service-exampletocold_api.service, edit it and and move to/etc/systemd/system/ - Copy
cold_reports.service-exampletocold_reports.service, edit it and and move to/etc/systemd/system/ - Reload the systemd daemon,
sudo systemctl daemon-reload - Enable the services (only needed the first time, may return a
warning about symbolic link)
sudo systemctl enable cold.servicesudo systemctl enable cold_api.servicesudo systemctl enable cold_reports.service
- Start the services using
systemctlin the usual waysudo systemctl start cold.servicesudo systemctl start cold_api.servicesudo systemctl start cold_reports.service
- Test web services using eLinks. If you get a gateway error it means datasetd isn’t running correctly in port 8111. Debug with curl, systemctl status, journalctl.
- Make sure the
htdocs/rptdirectory has the correct ownership and sticky bit set so that reports can be run from a cronjob and from the reports UI and not get “stuck”.
You can configure Apache to reverse proxy to the cold service running on port 8111 where it should enforce access control.
For a good description of how to setup new systemd services the Debian (works with Ubuntu too) way see https://wiki.debian.org/systemd/Services.
Here’s an example of the shell session based on the above list. I’m assuming the user/group you’re running things under is “www-data”.
ssh apps.example.edu
sudo mkdir -p /Sites/
sudo chgrp www-data /Sites/
sudo chmod 775 /Sites/
cd /Sites
git clone git@github.com:caltechlibrary/cold
cd cold
deno task setup
deno task build
cp cold.service-example cold.service
nano cold.service
sudo mv cold.service /etc/systemd/system/
cp cold_api.service-example cold_api.service
nano cold_api.service
sudo mv cold_api.service /etc/systemd/system/
cp cold_reports.service-example cold_reports.service
nano cold_reports.service
sudo mv cold_reports.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable cold.service
sudo systemctl enable cold_api.service
sudo systemctl enable cold_reports.service
sudo systemctl start cold.service
sudo systemctl start cold_api.service
sudo systemctl start cold_reports.service
elinks http://localhost:8111
sudo chown -R $USER:$USER htdocs/rpt
chmod +t htdocs/rpt
NOTE: The TypeScript services need to be compile before running them with Systemd.
Apache 2 and Shibboleth
COLD is designed to be a reverse proxy target. Using Apache you need to to include the following code in the main host definition.
#<!-- cold -->
ProxyPreserveHost On
Redirect "/cold" "/cold/"
ProxyPassMatch "^/cold/(.*)" "http://localhost:8111/$1"
ProxyPassReverse "/cold/" "http://localhost:8111/"
#<!-- cold admin -->
<Location /cold/>
AuthType shibboleth
ShibRequestSetting requireSession 1
require user rsdoiel@caltech.edu sdavison@caltech.edu tmorrell@caltech.edu tkeswick@caltech.edu kjohnson@caltech.edu melray@library.caltech.edu
#require valid-user
</Location>
#<!-- end cold -->
Example data migration from spreadsheets for CaltechPEOPLE
This is a note for migrating data from our historic spreadsheet for
CaltechPEOPLE. Once cold is installed and you’ve created the empty
dataset collections (e.g. people.ds) you can use two tools to populate
the collection and set the include_in_feeds property.
Steps:
- Set the environment variable FEEDS_BASE_DIR to point to where feeds staging is deployed.
- Copy people.csv and groups.csv from feeds.library.caltech.edu and
save then as
people_final.csvandgroups_final.csv. Copy edit the files if necessary (e.g. remove duplicate rows) - Copy the directory names for people on feeds.library.caltech.edu and
render this as a single CSV column
with the heading
clpid. - Clear test data from
people.dswith SQLite3 cli. - Run
ds_importer - Run
set_include_in_feeds
FEEDS_BASE_DIR="/Sites/feeds"
scp "library.example.edu:$FEEDS_BASE_DIR/people.csv" people_final.csv
echo "clpid" >in_feeds.csv
ssh library.example.edu "ls -1 -d $FEEDS_BASE_DIR/htdocs/people/* | cut -d / -f 6" >>in_feeds.csv
./bin/ds_importer people.ds people_final.csv
./bin/set_include_in_feeds people.ds in_feeds.csv