Skip to content

Commit

Permalink
reset
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 13, 2019
1 parent 7398a56 commit a7289c0
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .rultor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ release:
bundle install --no-color
ruby -v
LC_ALL=en_US.UTF-8 bundle exec rake
git remote add heroku git@heroku.com:zerorsk.git
git remote add dokku dokku@www.0rsk.com:zerorsk
rm -rf ~/.ssh
mkdir ~/.ssh
mv ../id_rsa ../id_rsa.pub ~/.ssh
Expand All @@ -38,7 +38,7 @@ release:
bundle exec rake config
git add config.yml
git commit -m 'config.yml'
git push -f heroku $(git symbolic-ref --short HEAD):master
git push -f dokku $(git symbolic-ref --short HEAD):master
git reset HEAD~1
rm -f target/pgsql-config.yml
bundle exec rake liquibase
Expand Down
1 change: 1 addition & 0 deletions CHECKS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ Login
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'iri', '0.4.1'
gem 'loog', '0.2.1'
gem 'minitest', '5.11.3', require: false
gem 'minitest-reporters', '1.3.6', require: false
gem 'pgtk', '0.7.1'
gem 'pgtk', '0.7.5'
gem 'rack', '2.0.6'
gem 'rack-ssl', '1.4.1'
gem 'rack-test', '1.1.0'
Expand Down
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GEM
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.1.5)
crass (1.0.4)
crass (1.0.5)
daemons (1.3.1)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
Expand All @@ -52,7 +52,7 @@ GEM
rake
eventmachine (1.2.7)
execjs (2.7.0)
faraday (0.16.2)
faraday (0.17.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.13.1)
faraday (>= 0.7.4, < 1.0)
Expand All @@ -62,7 +62,7 @@ GEM
haml (5.0.4)
temple (>= 0.8.0)
tilt
i18n (1.6.0)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
iri (0.4.1)
Expand All @@ -71,7 +71,7 @@ GEM
listen (3.2.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.3.0)
loofah (2.3.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
loog (0.2.1)
Expand All @@ -83,16 +83,16 @@ GEM
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.13.1)
multi_json (1.14.1)
multipart-post (2.1.1)
mustermann (1.0.3)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
parallel (1.17.0)
parallel (1.18.0)
parser (2.6.5.0)
ast (~> 2.4.0)
pg (1.1.4)
pgtk (0.7.1)
pgtk (0.7.5)
backtrace (~> 0.3)
loog (~> 0.2)
pg (~> 1.1)
Expand All @@ -108,8 +108,8 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.0)
actionpack (= 6.0.0)
activesupport (= 6.0.0)
Expand All @@ -128,7 +128,7 @@ GEM
listen (~> 3.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.5)
rspec-expectations (3.8.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.2)
Expand Down Expand Up @@ -209,7 +209,7 @@ GEM
nokogiri (~> 1.8)
rainbow (~> 3.0)
slop (~> 4.4)
zeitwerk (2.1.10)
zeitwerk (2.2.0)

PLATFORMS
ruby
Expand All @@ -226,7 +226,7 @@ DEPENDENCIES
loog (= 0.2.1)
minitest (= 5.11.3)
minitest-reporters (= 1.3.6)
pgtk (= 0.7.1)
pgtk (= 0.7.5)
rack (= 2.0.6)
rack-ssl (= 1.4.1)
rack-test (= 1.1.0)
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: LC_ALL=UTF-8 bundle exec ruby 0rsk.rb -p $PORT
web: bundle exec ruby 0rsk.rb -p $PORT
4 changes: 2 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cp /code/home/assets/0rsk/config.yml .
git add config.yml
git add Gemfile.lock
git add .gitignore
git commit -m 'config.yml for heroku'
git commit -m 'config.yml for dokku'
trap 'git reset HEAD~1 && rm config.yml && git checkout -- .gitignore' EXIT
git push heroku master -f
git push dokku master -f

161 changes: 161 additions & 0 deletions nginx.conf.sigil
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{{ range $port_map := .PROXY_PORT_MAP | split " " }}
{{ $port_map_list := $port_map | split ":" }}
{{ $scheme := index $port_map_list 0 }}
{{ $listen_port := index $port_map_list 1 }}
{{ $upstream_port := index $port_map_list 2 }}

{{ if eq $scheme "http" }}
server {
listen [::]:{{ $listen_port }};
listen {{ $listen_port }};
{{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
access_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-access.log;
error_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-error.log;
location / {

gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_vary on;
gzip_comp_level 6;

proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;

error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
location /400-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}

error_page 404 /404-error.html;
location /404-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}

error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
location /500-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}
}
{{ else if eq $scheme "https"}}
server {
listen [::]:{{ $listen_port }} ssl {{ if eq $.HTTP2_SUPPORTED "true" }}http2{{ else if eq $.SPDY_SUPPORTED "true" }}spdy{{ end }};
listen {{ $listen_port }} ssl {{ if eq $.HTTP2_SUPPORTED "true" }}http2{{ else if eq $.SPDY_SUPPORTED "true" }}spdy{{ end }};
{{ if $.SSL_SERVER_NAME }}server_name {{ $.SSL_SERVER_NAME }}; {{ end }}
{{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
access_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-access.log;
error_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-error.log;

ssl_certificate {{ $.APP_SSL_PATH }}/server.crt;
ssl_certificate_key {{ $.APP_SSL_PATH }}/server.key;
ssl_protocols TLSv1.2 {{ if eq $.TLS13_SUPPORTED "true" }}TLSv1.3{{ end }};
ssl_prefer_server_ciphers off;

keepalive_timeout 70;
{{ if and (eq $.SPDY_SUPPORTED "true") (ne $.HTTP2_SUPPORTED "true") }}add_header Alternate-Protocol {{ $.PROXY_SSL_PORT }}:npn-spdy/2;{{ end }}

location / {

gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_vary on;
gzip_comp_level 6;

proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
{{ if eq $.HTTP2_PUSH_SUPPORTED "true" }}http2_push_preload on; {{ end }}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;

error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
location /400-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}

error_page 404 /404-error.html;
location /404-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}

error_page 500 501 503 504 505 506 507 508 509 510 511 /500-error.html;
location /500-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}

error_page 502 /502-error.html;
location /502-error.html {
root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
internal;
}
}
{{ else if eq $scheme "grpc"}}
{{ if eq $.GRPC_SUPPORTED "true"}}{{ if eq $.HTTP2_SUPPORTED "true"}}
server {
listen [::]:{{ $listen_port }} http2;
listen {{ $listen_port }} http2;
{{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
access_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-access.log;
error_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-error.log;
location / {
grpc_pass grpc://{{ $.APP }}-{{ $upstream_port }};
}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
}
{{ end }}{{ end }}
{{ else if eq $scheme "grpcs"}}
{{ if eq $.GRPC_SUPPORTED "true"}}{{ if eq $.HTTP2_SUPPORTED "true"}}
server {
listen [::]:{{ $listen_port }} ssl http2;
listen {{ $listen_port }} ssl http2;
{{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
access_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-access.log;
error_log {{ $.NGINX_LOG_ROOT }}/{{ $.APP }}-error.log;

ssl_certificate {{ $.APP_SSL_PATH }}/server.crt;
ssl_certificate_key {{ $.APP_SSL_PATH }}/server.key;
ssl_protocols TLSv1.2 {{ if eq $.TLS13_SUPPORTED "true" }}TLSv1.3{{ end }};
ssl_prefer_server_ciphers off;

location / {
grpc_pass grpc://{{ $.APP }}-{{ $upstream_port }};
}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
}
{{ end }}{{ end }}
{{ end }}
{{ end }}

{{ if $.DOKKU_APP_LISTENERS }}
{{ range $upstream_port := $.PROXY_UPSTREAM_PORTS | split " " }}
upstream {{ $.APP }}-{{ $upstream_port }} {
{{ range $listeners := $.DOKKU_APP_LISTENERS | split " " }}
{{ $listener_list := $listeners | split ":" }}
{{ $listener_ip := index $listener_list 0 }}
server {{ $listener_ip }}:{{ $upstream_port }};{{ end }}
}
{{ end }}{{ end }}
4 changes: 3 additions & 1 deletion objects/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def postpone(id, seconds)
@pgsql.transaction do |t|
t.exec('DELETE FROM task WHERE id = $1', [id])
s = (Time.now + seconds).strftime('%d-%m-%Y')
Rsk::Plans.new(@pgsql, row['project'].to_i).get(row['id'].to_i, row['part'].to_i).schedule = s
plan = Rsk::Plans.new(@pgsql, row['project'].to_i).get(row['id'].to_i, row['part'].to_i)
raise Rsk::Urror, "Can't postpone plan ##{row['id']}" if /^[a-z]+$/.match?(plan.schedule)
plan.schedule = s
end
end

Expand Down
13 changes: 8 additions & 5 deletions views/tasks.haml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@
%span.item<
&= t[:schedule]
%a.item{href: iri.cut('/tasks/done').add(id: t[:id])} Done
%span.item
Later:
%a.item{href: iri.cut('/tasks/later').add(id: t[:id], period: 'week')} week
%a.item{href: iri.cut('/tasks/later').add(id: t[:id], period: 'month')} month
%a.item{href: iri.cut('/tasks/later').add(id: t[:id], period: 'quarter')} quarter
- unless /^[a-z]+$/.match?(t[:schedule])
%span.item
Later:
%a{href: iri.cut('/tasks/later').add(id: t[:id], period: 'week')} week
= '|'
%a{href: iri.cut('/tasks/later').add(id: t[:id], period: 'month')} month
= '|'
%a{href: iri.cut('/tasks/later').add(id: t[:id], period: 'quarter')} quarter
= Haml::Engine.new(File.read('views/_paging.haml')).render(self, locals.merge(count: tasks.count))

%p
Expand Down

0 comments on commit a7289c0

Please sign in to comment.