-
Notifications
You must be signed in to change notification settings - Fork 35
4.0.0 Vireo Deployment AWS
This deployment was successfully tested on a Digital Ocean $10/month 2GB ubuntu 16.04 droplet with 1 CPU. The 1GB $5 droplet was unusable for building vireo4 - presumably a shortage of memory kept npm from building assets. Installations may vary on other systems.
A docker deployment is available at https://github.com/TexasDigitalLibrary/Vireo4Docker
The vireo install will need PostgreSQL. The H2 database can be used for testing but PostgreSQL will be needed for persistence across reboots. MySQL is not yet supported.
The base system will need npm, nodejs, grunt and maven. Nodejs is needed for processing assets.
The base system will also need git but this typically comes with the base linux system.
Vireo will also need java 1.8 developer kit.
Edits to src/main/resources/application.yaml will also be needed.
Finally the install should use a proxy web server such as Apache2 or Nginx.
Call apt-get update to be ready for other installs.
apt-get update
git --version
Typically it is already part of the base linux system but it may need to be explicitly installed. If so:
apt-get install git
apt-get install maven
apt-get install default-jdk
This is the most system specific problem for deployments. This section may be different for later versions of ubuntu or AWS variants.
apt-get install npm
apt-get install nodejs-legacy
npm install -g grunt-cli
Set up an account under which the deploy will be performed. For these instructions we'll use the account named 'vireo.'
Add user 'vireo' and then enter a requested initial password.
adduser vireo4
Enter password and requested information, or hit return and end with a 'Y' to confirm.
Give user 'vireo4' root level privileges:
/usr/sbin/visudo
Add the following line beneath the similar line for root:
vireo4 ALL=(ALL:ALL) ALL
Enter Control-X, 'Y', and then [return] to exit the editor.
Uploaded documents are stored in the operating systems directory structure. Create a [assets_store] directory such as /opt/vireo for these files.
mkdir /opt/vireo/
Sign in as vireo4. Create a directory in vireo4 such as /home/vireo4/etd/ in which to clone Vireo:
mkdir /home/vireo4/etd/
cd /home/vireo4/etd/
git clone https://github.com/TexasDigitalLibrary/Vireo.git
cd Vireo
Use the default master branch or change to the latest point release branch of Vireo4
git checkout 4.0.x
Try to start vireo4 using spring boot to verify that it has everything it needs to build and run.
mvn clean spring-boot:run -Drun.arguments=console
After several minutes of downloads and processing you will see a generate> prompt. If you get this far then your system is set up properly. Use Control-C or other means to kill this process. If it failed review previous steps and verify the version of OS you are using. Most problems are related to getting the right npm and node versions for the OS.
If you point your browser to your URL or IP address followed by the port number, e.g. http://example.edu:9000, you will see a poorly formatted vireo page. This is OK. The presentation of this page will be remedied by changes to application.yaml further down.
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
Answer 'Y' to the prompt.
sudo su - postgres
psql
This will give you a 'postgres=#' prompt.
Create role 'vireodb', give privileges, and create database vireo.
postgres=# CREATE ROLE vireodb WITH LOGIN PASSWORD '[your_vireo_postgres_password]';
postgres=# ALTER ROLE vireodb CREATEDB;
postgres=# CREATE DATABASE vireo;
postgres=# GRANT ALL PRIVILEGES ON DATABASE vireo TO vireodb;
postgres=# \q
Exit from the postgres account so you will be back in the vireo4 account.
exit
A few values will be set at the command line but some should be set in the file:
Set a port. For this install we will change port 9000 to port 8080 as we'll be running with embedded tomcat:
server:
#port: 9000
port: 8080
Set the database access by commenting out the H2 section and uncommenting the platform, url, and driverClassName in the PostgreSQL entry. Modify as needed for your particular setup (i.e. you elected a different port number):
spring:
datasource:
platform: postgresql
url: jdbc:postgresql://localhost:5432/vireo
driverClassName: org.postgresql.Driver
Also under datasource, set the database role name and password (as set in the Install PostreSQL section):
username: vireodb
password: [your_vireo_postgres_password]
Comment/uncomment the jpa entry to select the correct database-platform for PostgreSQL:
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
In the same section change:
hibernate.ddl-auto: create-drop
To:
hibernate.ddl-auto: update
Set the application URL with your url and port number, such as 'http://etd.example.edu:8080':
app:
url: [your url and port number]
Note that the values which appear under info: build: will be filled either via the pom.xml or the command line.
Finally, set the email relay and addresses:
email:
host: [your_smtp_relay] #e.g. smtp-relay.example.edu
from: [your_outbound_address] #e.g. [email protected]
replyTo: [your_replyto_address] #e.g. [email protected]
If you want to give users some sample accounts to experiment with, you will need to start vireo enabled with a command line interface. Use the -Drun.argumets=console flag, which only works when started with spring-boot.
mvn clean spring-boot:run -Drun.arguments=console
Once you get the prompt:
generate> generate 3
generate> accounts 3
generate> admin_accounts 3
If you sign back in to the database you can see the accounts:
sudo su - postgres
psql
postgres=# \c vireo
postgres=# SELECT * FROM weaver_users;
postgres=# \q
exit
Build production mode war file with assets.uri specified:
mvn clean package -Dproduction -Dassets.uri=file:[assets_path]
#e.g. mvn clean package -Dproduction -Dassets.uri=file:/opt/vireo
Run it with the following command using the appropriate war file name based on [version-tag]:
nohup java -jar target/vireo-4.0.0-[version-tag].jar &
e.g. nohup java -jar target/vireo-4.0.0-RC.jar &
Create the file /home/vireo4/etd/vireo4.sh and add the following 2 lines using the appropriate war file name based on [version-tag].
#!/bin/sh
sudo -u vireo4 /usr/bin/java -jar /home/vireo4/etd/Vireo/target/vireo-4.0.0-[version-tag].war
Change the file permissions with:
chmod 0764 vireo4.sh
Create /etc/systemd/system/vireo4.service
[Unit]
Description= Vireo 4 ETD service
[Service]
User=vireo4
#This must point to the Vireo base path
WorkingDirectory=/home/vireo4/etd/Vireo/
#This is a path to a bash script which launches war file with embedded tomcat8
ExecStart=/home/vireo4/etd/vireo4.sh
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Reload the systemd configuration and enable the vireo4 service to start automatically upon reboot:
sudo systemctl daemon-reload
sudo systemctl enable vireo4.service
Start, check status, stop the service, or check if it is enabled with:
sudo systemctl start vireo4
sudo systemctl status vireo4
sudo systemctl stop vireo4
sudo systemctl is-enabled vireo4
To test:
sudo reboot
This example uses nginx.
sudo apt-get install nginx
We'll need a certificate:
sudo add-apt-repository ppa:certbot/certbot
The next command will provide a 'not available' error unless it is immediately preceded by an apt-get update:
sudo apt-get update
sudo apt-get install python-certbot-nginx
Edit /etc/nginx/sites-available/default so that your URL replaces '_' after server_name such as:
server_name [your_url];
Create the certificates for nginx:
sudo certbot --nginx -d [your_url_with_no_protocol]
e.g. sudo certbot --nginx -d etd.example.edu
You will be asked several questions via prompts. The third one is for redirecting HTTP traffic, respond with a '2' if you want all HTTP traffic redirected to HTTPS (recommended).
Try pointing your browser to your url with no port. you will see an nginx page.
Go back and edit default
sudo vi /etc/nginx/sites-enabled/default
You will see that the earlier certbot command added, port 443 and ssl_certificate related entries to default.
Comment out:
#root /var/www/html;
and change location so it looks like:
location / {
proxy_pass http://127.0.0.1:8080/;
}
Since we are using a different protocol and port, go back and edit src/main/resources/application.yaml to change your app:url::
app:
url: https://etd.example.edu
Stop the vireo4 service, rebuild the war file, and restart the vireo4 service.
You may also need to clean your browser's cache, especially if you see the vireo page with no formatting or other assets.
Nginx should have picked up the location changes. If not then restart the service it with systemctl:
systemctl restart nginx
You should be able to access vireo4 at your such as https://etd.example.edu
Register your account on the vireo4 website.
There are 4 types of accounts: Admin, Manager, Reviewer, and Student. The Admin account will manage the site for the whole institution. You may need to manually set an initial Administrative permission on an account. This account can then be used to set permissions on other accounts through the user interface.
sudo su - postgres
psql
postgres=# UPDATE weaver_users SET role='ROLE_ADMIN' WHERE id=[user_id_in_weaver_users_table_you_want_to_make_admin];
postgres=#\q
exit
While signed in under the unix vireo account create a directory for the backups and create a crontab entry
> mkdir /home/vireo/backups/
> crontab -e
Create an entry such as:
0 1 * * * pg_dump vireo > /home/vireo/backups/vireo_backup_`date +\%Y_\%m_\%dT\%H:\%M:\%S`.sql
This creates a file in your backups directory with a date stamp such as:
vireo_backup_2019_05_13T09:53:47.sql
To restore use:
> sudo -u postgres psql
postgres=# DROP DATABASE vireo;
postgres=# CREATE DATABASE vireo;
postgres=# \q
> sudo -u postgres psql -U postgres vireo < /tmp/vireo_backup_2019_05_13T09\:53\:47.sql
> nohup java -jar target/vireo-4.0.0-SNAPSHOT.jar &
If you are having trouble accessing your database, verify the port on which which PostgreSQL is running. The default is 5432.
sudo -u postgres psql
postgres=# SELECT * FROM pg_settings WHERE name = 'port';
postgres=# \q
exit
If you prefer running vireo4 as a jar file this can be generated by changing one line in the pom.xml file:
Edit pom.xml to use jar instead of war. Change:
<packaging>war</packaging>
to
<packaging>jar</packaging>