Portal MEC
License
Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre Departamento de Informatica - Universidade Federal do Parana
This file is part of portalmec.
portalmec is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
portalmec is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with portalmec. If not, see http://www.gnu.org/licenses/.
Requirements
- rvm
- Using rvm you will install ruby "2.3.1"
- ruby "2.3.1"
- Dspace server "5.x"
- Postgres (>= 9.6, <=10)
- If you will install Dspace, it is recommended to use Postgres "9.6"
- Elasticsearch "6.2.4"
- Redis
- nvm
- Using nvm you will install Node.js "8.10.0"
NVM and Node.js
For install NVM and Node.js, use this follwing commands:
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
$ source ~/.bashrc
$ nvm install 8.10.0
Postgres
After the first install, you can run this commands:
sudo passwd postgres
su postgres
psql -c "ALTER USER postgres WITH PASSWORD '$PASSWORD'" -d template1
createuser -h localhost -U postgres -d $USER_DB
psql -c "ALTER USER $USER_DB WITH PASSWORD '$PASSWORD'" -d template1
Note: You can ask for the database dump for someone in the project.
You need to modify the file "/etc/postgresql/10/main/pg_hba.conf", the modification is
* comment the 1st and 2nd lines with "peer" and copy them replacing "peer" with "md5".
After this, run this command:
systemctl stop postgresql
systemctl start postgresql
Rvm
After finish the installer, you will need to add in your ~/.bashrc this commands:
export PATH="$PATH:$HOME/.rvm/bin"
source /home/Your_user/.rvm/scripts/rvm
After this, run the command source ~/.bashrc
.
Note
: If does not work, you can try modify the commands above, for this:
export PATH="$PATH:/usr/share/rvm/bin"
source /usr/share/rvm/scripts/rvm
Setup
First of all, you need to configure the dspace, elasticsearch and redis servers. Create an user for postgres database. After this setup, open the configuration files inside the project repository and update the following files:
* config/database.yml: change your postgres credentials for development and test environment.
* config/dspace.yml: change your dspace host and credentials for development and test environment.
* config/sidekiq.yml: change your redis hosts and ports.
* config/initializers/elasticsearch.rb: inside elsif Rails.env.test? change url 'elasticsearch:9200' to 'localhost:9200'.
* config/initializers/gitlab.rb: change your gitlab host for bug reports and set env var with private token. ( $ export GITLAB_PORTALMEC_PRIVATE_TOKEN=131237128937128937 )
Install
After installed the requeriments, the first you will need to do is run:
bundle install
This command will install all required gems for the project.
Note
: Sometimes some gems throw errors. That is because there is a chance that you do not have all the required dependecies for the installation of the gem that failed to install. Please install the dependencies and try again.
After all gems were installed succesfuly. Please create the database using the following commands:
rake db:create
- If you have the dump of the database, use it before db:migrate.
- To use the dump, run this commands:
psql -U $DATABASE_USER -d $DATABASE_NAME < $DATABASE_PATH/dump_name.sql
- To use the dump, run this commands:
rake db:migrate
Note
: You need to load the dump in the database_dev.
This procedure will create and configure all table in the project database
For the search mechanism to works, it is required to copy your_directory_path/portalmec/calculate_score.painless
to /etc/elasticsearch/scripts
. After this is done,
execute the CMD in the portalmec directory rake searchkick:reindex:all
.
Once finished, your application is read to be used. To acess it, run CMD:
bundle exec rails s
For tests, run this commands:
-
export DSPACE_LOGIN=your_login
-
export DSPACE_PASS=your_password
-
source ~/.bashrc
-
bundle exec rake spec:acceptance
Production environment
As you set development and test environment vars, now production vars will be needed to be set.
For that, open the file config/env_vars.sh and set them. After, run:
./config/env_vars.sh
* Redis vars need to be set on config/sidekiq.yml
* In config/initializers/devise.rb, change the emails addresses. (Ex.: config.mailer_sender = 'suporte@c3sl.ufpr.br')
Now that your application is ready, you can run it using sames commands used in the install section.
After the setup, link your webserver to the app. Some OS services are in root of the project and can be used.