Skip to content

Commit

Permalink
Usa sip2.0b11 y sus convenciones, ver https://github.com/pasosdeJesus…
Browse files Browse the repository at this point in the history
  • Loading branch information
vtamara committed Feb 5, 2021
1 parent 1faf028 commit c49b093
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 59 deletions.
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CONTRIBUCIONES

Aplican los mismos lineamientos descritos en:
<https://github.com/pasosdeJesus/sip/blob/master/CONTRIBUTING.md>

Respecto a la aplicación de prueba, una vez la configure e ingrese
a la aplicación desde un navegador en el punto de montaje `/jn316`,
utilice el usuario administrador `jn316` con clave `jn316`.



6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ gem "will_paginate" # Listados en páginas
# lógico y no alfabetico como las gemas anteriores)

gem 'sip', # Motor generico
git: 'https://github.com/pasosdeJesus/sip.git'
git: 'https://github.com/pasosdeJesus/sip.git', branch: :main
#gem 'sip', path: '../sip'


group :development, :test do
#gem 'byebug', platform: :mri

gem 'colorize'

gem 'dotenv-rails'

gem 'puma'
end


Expand Down
18 changes: 12 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
GIT
remote: https://github.com/pasosdeJesus/sip.git
revision: 442e2281c33715eb8a135fad10eb9e7f98e4f900
revision: 614df30c836b34cec2a8ff581e384662eef69a8e
branch: main
specs:
sip (2.0.b10)
sip (2.0.b11)
cancancan
chosen-rails
devise
Expand Down Expand Up @@ -92,7 +93,7 @@ GEM
bcrypt (3.1.16)
bigdecimal (3.0.0)
bindex (0.8.1)
bootsnap (1.6.0)
bootsnap (1.7.1)
msgpack (~> 1.0)
builder (3.2.4)
camertron-eprun (1.1.1)
Expand Down Expand Up @@ -122,12 +123,16 @@ GEM
devise-i18n (1.9.2)
devise (>= 4.7.1)
docile (1.3.5)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
erubi (1.10.0)
execjs (2.7.0)
ffi (1.14.2)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.7)
i18n (1.8.8)
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -263,7 +268,7 @@ GEM
zeitwerk (2.4.2)

PLATFORMS
ruby
x86_64-openbsd

DEPENDENCIES
bcrypt
Expand All @@ -275,6 +280,7 @@ DEPENDENCIES
colorize
devise
devise-i18n
dotenv-rails
jbuilder (~> 2.5)
jn316_gen!
net-ldap
Expand All @@ -296,4 +302,4 @@ DEPENDENCIES
will_paginate

BUNDLED WITH
2.1.4
2.2.3
80 changes: 74 additions & 6 deletions test/dummy/.env.plantilla
Original file line number Diff line number Diff line change
@@ -1,7 +1,75 @@
export RAILS_RELATIVE_URL_ROOT=/
export RAILS_ENV=development # Modo (development o production)
export IPDES=192.168.1.3 # IP en modo de desarrollo con http
export PUERTODES=2300 # Puerto en modo desarrollo con http
#!/bin/sh
# Variables de configuración de la aplicación
# Damos precedencia a las especificadas en línea de ordenes


# Base de datos
if (test "$BD_USUARIO" = "") then {
export BD_USUARIO=sipdes
} fi;
if (test "$BD_CLAVE" = "") then {
export BD_CLAVE=xyz
} fi;
if (test "$BD_DES" = "") then {
export BD_DES=jn316gen_des
} fi;
if (test "$BD_PRUEBA" = "") then {
export BD_PRUEBA=jn316gen_pru
} fi;
if (test "$BD_PRO" = "") then {
export BD_PRO=jn316gen_pro
} fi;



# Despliegue común en desarrollo y producción
if (test "$CONFIG_HOSTS" = "") then {
export CONFIG_HOSTS=192.168.10.1
} fi;
if (test "$RUTA_RELATIVA" = "") then {
export RUTA_RELATIVA=/jn316/
} fi;
if (test "$DIRAP" = "") then {
export DIRAP="$HOME/comp/rails/jn316_gen/test/dummy"
} fi;
if (test "$RAILS_ENV" = "") then {
export RAILS_ENV=development
} fi;


# Despliegue en modo desarrollo
if (test "$IPDES" = "") then {
export IPDES=192.168.10.1
} fi;
if (test "$PUERTODES" = "") then {
export PUERTODES=3000
} fi;


# Despliegue en modo producción con unicorn
if (test "$RC" = "") then {
export RC=sip
} fi;
if (test "$PUERTOUNICORN" = "") then {
export PUERTOUNICORN=3015
} fi;
if (test "$USUARIO_AP" = "") then {
export USUARIO_AP=miusuario
} fi;
if (test "$SECRET_KEY_BASE" = "") then {
export SECRET_KEY_BASE=123456789abcdef
} fi;


# Configuraciones de sip
if (test "$SIP_FORMATO_FECHA" = "") then {
export SIP_FORMATO_FECHA='dd/M/yyyy'
} fi;
if (test "$SIP_RUTA_ANEXOS" = "") then {
export SIP_RUTA_ANEXOS=${DIRAP}/archivos/anexos
} fi;
if (test "$SIP_RUTA_VOLCADOS" = "") then {
export SIP_RUTA_VOLCADOS=${DIRAP}/archivos/bd
} fi;


# export IPDES="ssl://192.168.1.3:2300?key=tmp/llave-privada.key&cert=tmp/llave-publica.crt" # IP en modo desarrollo con https
# export PUERTODES= # Puerto en modo desarrollo con https
27 changes: 19 additions & 8 deletions test/dummy/bin/corre
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ FileUtils.chdir RAIZ_AP do
end
puts "\n== Ejecutando aplicacion #{ENV['RC']} =="

if !File.exists?('/tmp/node')
puts "\n== Enlace a /usr/local/bin/node desde /tmp =="
system! 'doas ln -s /usr/local/bin/node /tmp'
end

if !ENV['RAILS_ENV'] || ENV['RAILS_ENV'] == ''
ENV['RAILS_ENV'] = 'development'
end
Expand All @@ -55,36 +60,42 @@ FileUtils.chdir RAIZ_AP do
system! 'CXX=c++ bin/yarn'

puts "\n== Preparando base de datos =="
system! 'bin/rails db:prepare'
system! "RAILS_ENV=#{ENV['RAILS_ENV']} bin/rails db:prepare"

puts "\n== Actualizando índices =="
system!('bin/rails sip:indices')
system!("RAILS_ENV=#{ENV['RAILS_ENV']} bin/rails sip:indices")

puts "\n== Eliminando bitácoras, archivos temporales y recursos =="
system! 'bin/rails log:clear tmp:clear'
system! 'rm -rf public/packs/*'
system! "rm -rf public/#{ENV['RAILS_RELATIVE_URL_ROOT']}/assets/*"

puts "\n== Crea recursos CSS y Javascript =="
system! 'bin/rails assets:precompile --trace'
system! "RAILS_ENV=#{ENV['RAILS_ENV']} bin/rails assets:precompile --trace"
end

if ENV['RAILS_ENV'] == "development"
puts "\n== Ejecutando en modo desarrollo =="
ord = "bin/rails s"

ord = ""
if ENV['CONFIG_HOSTS'] && ENV['CONFIG_HOSTS'] != ''
ord += "CONFIG_HOSTS=#{ENV['CONFIG_HOSTS'].downcase} "
end
ord += "RAILS_RELATIVE_URL_ROOT='' "
ord += "bin/rails s "
if ENV['PUERTODES'] != ''
ord += " -p #{ENV['PUERTODES']}"
ord += "-p #{ENV['PUERTODES']} "
end
ord += " -b '#{ENV['IPDES']}'"
ord += "-b '#{ENV['IPDES']}' "
puts "#{ord}"
system!(ord)
elsif ENV['RAILS_ENV'] == 'production'
if !File.exist("/etc/rc.d/#{ENV['RC']}")
puts "\nFalta script /etc/rc.d/#{ENV['RC']}"
exit 1
end
puts "\n== Ejecutando en modo producción =="
system!("doas sh /etc/rc.d/#{ENV['RC']} -d start")
ord = "doas sh /etc/rc.d/#{ENV['RC']} -d start"
end
system!(ord)

end
19 changes: 19 additions & 0 deletions test/dummy/bin/detiene
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# Detiene servicio

if (test -f ".env") then {
. .env
} fi;
if (test "$RC" = "") then {
echo "Falta RC en .env"
exit 1
} fi;
if (test "$RAILS_ENV" = "production") then {
if (test ! -f /etc/rc.d/$RC) then {
echo "Falta script /etc/rc.d/$RC"
exit 1;
} fi;

doas sh /etc/rc.d/$RC -d stop
} fi;

40 changes: 40 additions & 0 deletions test/dummy/bin/migra
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
# Actualiza fuentes y base de datos

if (test -f ".env") then {
. .env
} fi;
if (test "${RAILS_ENV}" = "") then {
RAILS_ENV=development
} fi;
bin/detiene
if (test "$?" != "0") then {
echo "Problema al detener";
exit 1;
} fi;
git pull
if (test "$?" != "0") then {
echo "Problema con git pull";
exit 1;
} fi;
bundle install
if (test "$?" != "0") then {
echo "Problema con bundle install";
exit 1;
} fi;
CXX=c++ yarn install
echo "BD_USUARIO=${BD_USUARIO}"
echo "BD_CLAVE=${BD_CLAVE}"
echo "BD_DES=${BD_DES}"
bin/rails db:prepare RAILS_ENV=$RAILS_ENV BD_USUARIO=$BD_USUARIO \
BD_CLAVE=$BD_CLAVE BD_PRO=$BD_PRO BD_DES=$BD_DES BD_PRUEBA=$BD_PRUEBA
if (test "$?" != "0") then {
echo "Problema con db:migrate";
exit 1;
} fi;
bin/corre
if (test "$?" != "0") then {
echo "Problema al volver a iniciar";
exit 1;
} fi;

Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: sipdes
password: xyz
username: <%= ENV['BD_USUARIO'] || 'sipdes' %>
password: <%= ENV['BD_CLAVE'] %>
host: /var/www/var/run/postgresql

development:
<<: *default
database: jn316gen_des
database: <%= ENV['BD_DES'] || 'jn316gen_des' %>

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: jn316gen_pru
database: <%= ENV['BD_PRUEBA'] || 'jn316gen_pru' %>

production:
<<: *default
database: jn316gen_prod
database: <%= ENV['BD_PRO'] || 'jn316gen_pro' %>
4 changes: 4 additions & 0 deletions test/dummy/config/initializers/punto_montaje.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Dummy::Application.config.relative_url_root = ENV.fetch(
'RUTA_RELATIVA', '/jn316')
Dummy::Application.config.assets.prefix = ENV.fetch(
'RUTA_RELATIVA', '/jn316') + '/assets'
17 changes: 10 additions & 7 deletions test/dummy/config/initializers/sip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
require 'jn316_gen/version'

Sip.setup do |config|
config.ruta_anexos = "#{Rails.root}/archivos/anexos/"
config.ruta_volcados = "#{Rails.root}/archivos/bd"
# En heroku los anexos son super-temporales
if !ENV["HEROKU_POSTGRESQL_GREEN_URL"].nil?
config.ruta_anexos = "#{Rails.root}/tmp/"
end
config.titulo = "Jn316 - Gen " + Jn316Gen::VERSION

config.ruta_anexos = ENV.fetch('SIP_RUTA_ANEXOS',
"#{Rails.root}/archivos/anexos")
config.ruta_volcados = ENV.fetch('SIP_RUTA_VOLCADOS',
"#{Rails.root}/archivos/bd")
# En heroku los anexos son super-temporales
if !ENV["HEROKU_POSTGRESQL_GREEN_URL"].nil?
config.ruta_anexos = "#{Rails.root}/tmp/"
end
config.titulo = "Jn316 - Gen #{Jn316Gen::VERSION}"
end
Loading

0 comments on commit c49b093

Please sign in to comment.