iOS app preview 동영상 생성 방법

iOS의 앱 미리보기 (app preview) 동영상(video) 를 올리고 싶을 경우,
동영상 편집을 해야하는데 상당히 번거롭습니다.

간단히 만드는 법을 여기 기록 합니다.

화면 기록(실제 디바이스)

실제 디바이스에서 화면기록을 이용합니다.

설정 > 제어 센터 > 제어 항목 사용자화
위의 메뉴로 들어가서 화면 기록 을 위로 올려서 손전등, 카메라 등이 있는 빠른 메뉴에 화면기록을 추가합니다.

디바이스가 없을 경우

실제 디바이스가 없는 경우, 저는 iPad가 없는데 iPad의 동영상을 만들고 싶은 경우 입니다.

이때는 시뮬레이터를 실행 하고, 아래 명령을 실행합니다.

xcrun simctl io booted recordVideo app-preview-video.mov

화면 녹화 후에 는 ctrl+c 로 종료합니다.

편집

동영상 원본이 만들어졌다면 이제 편집이 필요합니다.
전 빠르게 재생하고 싶었습니다.

iMovie 를 이용합니다.

App Store 에서 iMovie 를 설치하고 실행합니다.

파일 > 새로운 앱 미리보기를 선택해서 새로운 app preview 프로젝트를 생성합니다.

프로젝트 생성 후 비디오 동영상 원본소스를 추가합니다.

하단의 창에 동영상 원본소스를 끌어다 놓습니다.

중요
오디오 파일을 아무거나 추가하고 하단의 창에 오디오 소스를 끌어다 놓습니다.

우상단의 아이콘중 계기판 표시를 선택해서 원하는 재생 스피디를 결정합니다.
또 소리를 선택해서 소리를 0% 로 변경합니다.
만약 본인의 음악파일이 저작권이 있다면 볼륨을 올리셔도 무방합니다.

편집이 완료되었다면, 우상단의 공유 버튼을 누르고, 앱 미리보기 를 선택해서 파일로 저장합니다.

이제 앱스토에서 동영상을 올리기만 하면 됩니다.

golang migrate 사용시 에러

필요성

예전 golang 코드에 사용하고 있는 db migration 관리 라이브러리: migrate이 라이브러리는 기존 레포에서,
GitHub – mattes/migrate: Database migrations. CLI and Golang library. ->
아래 레포로 리포지토리가 변경되어 관리 중에 있었습니다.
GitHub – golang-migrate/migrate: Database migrations. CLI and Golang library.

기존 코드 수정이 필요해서 README 를 읽기 위해 들어왔다가 기존 코드가 예전과는 다르게 변경, 관리되는 것을 알게되어서 레포 변경을 하기로 마음을 먹었습니다.

문제

migrate up


변경 후 migrate up 실행시에 아래와 같은 문제가 발생했습니다.

error: pq: column “dirty” does not exist in line 0 · Issue #34 · golang-migrate/migrate · GitHub

아마 dirty 컬럼이 추가 된 듯 합니다.
dirty column 을 수동으로 추가해줍니다.

alter table schema_migrations add column dirty boolean not null default false;

다시 migrate 를 실행하면 정상동작합니다.

Postgres driver 를 사용할때 발생하는 문제


  • Postgres driver 를 사용할때 발생하는 문제
  • Migrate 라이브러리 import 후에 New, Up 코드 작성
  • Compile and Run
  • have panic….
panic: sql: Register called twice for driver postgres

goroutine 1 [running]:
database/sql.Register(0x1f34e5d, 0x8, 0x2794580, 0x281b590)
        /Users/ktg/.gvm/gos/go1.9/src/database/sql/sql.go:50 +0x1ad
github.com/golang-migrate/migrate/vendor/github.com/lib/pq.init.0()
        /Users/ktg/go/src/github.com/golang-migrate/migrate/vendor/github.com/lib/pq/conn.go:49 +0x5c
github.com/golang-migrate/migrate/vendor/github.com/lib/pq.init()
        <autogenerated>:1 +0x782
github.com/golang-migrate/migrate/database/postgres.init()
        <autogenerated>:1 +0x7d
devops-mocha3/cmd/mocha/setup.init()
        <autogenerated>:1 +0x5d
main.init()
        <autogenerated>:1 +0x78

처음엔 뭘 잘못 했나 싶어서 이것 저것 해봤는데, 동일 증상…

그러다 이런 글 발견
Driver is being registered twice · Issue #238 · lib/pq · GitHub

이번 문제는 vendor에 있는 파일(lib/pg)을 한번 호출 하고, 다시 GOPATH 에 있는 파일을 호출한 것.

수정을 위해 dep ensure 실행을 해줍니다.
그리고 다시 컴파일 후 실행하면 정상동작합니다.

피타고라스 계산기

배관일하는 친구가 자꾸 삼각형의 빗변(피타고라스….)를 구해달라고 한다. 계산기가 없다면서…

귀찮아서 여기에 만들어두고 링크를 주련다…

 

밑변
높이

빗변

Rails 5.2 업데이트 시 문제점 정리

Rails 5.2 업데이트 시 문제점 정리

개인 프로젝트로 관리중인 rails web serverruby version 을 올리는 김에 같이 업데이트를 하려고 합니다.

기존 버전은 rails 5.0.3 이었고, 이번에 rails 5.2.0 으로 올리고 만난 에러들을 기록하려고 글을 씁니다.

Update

먼저 Gemfile.lock 을 지우고 과감하게 update 룰 합니다.

rm Gemfile.lock
bundle update

Gemfile 을 열어보면 rails 5.2를 확인할 수 있습니다.

업데이트가 안되었다면, 강제로 rails 만 업데이트 해줍니다.

bundle update rails -v 5.2.0

내가 만난 문제들


“Rack::Cors” String 문제

업데이트가 잘 되었으면 console 을 실행합니다.

rails c

output

$ rails c
/Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:37:in `build': undefined method `new' for "Rack::Cors":String
Did you mean?  next (NoMethodError)
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `block in build'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `inject'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `build'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/engine.rb:510:in `block in app'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/engine.rb:506:in `synchronize'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/engine.rb:506:in `app'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `call'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
    from /Users/ktg/privates/my_projects/config/environment.rb:5:in `<top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from -e:1:in `<main>'

위의 에러가 났습니다.

이 에러는 application.rb 내부의 Rack::Cors 문제입니다. 아래 링크에 해결책이 자세히 나와있습니다.

ruby – Error when running Rails application – Stack Overflow

raise_in_transactional_callbacks 문제

/Users/ktg/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/railtie.rb:124:in `block (3 levels) in <class:Railtie>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/railtie.rb:123:in `each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/railtie.rb:123:in `block (2 levels) in <class:Railtie>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/base.rb:328:in `<module:ActiveRecord>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/base.rb:27:in `<top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:247:in `block in load_dependency'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:653:in `new_constants_in'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:247:in `load_dependency'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    from /Users/ktg/privates/my_projects/app/models/application_record.rb:1:in `<top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:468:in `load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:468:in `block in load_file'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:653:in `new_constants_in'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:467:in `load_file'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:365:in `block in require_or_load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:13:in `loading'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in `load_interlock'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:348:in `require_or_load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:502:in `load_missing_constant'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:193:in `const_missing'
    from /Users/ktg/privates/my_projects/app/models/user.rb:1:in `<top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:468:in `load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:468:in `block in load_file'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:653:in `new_constants_in'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:467:in `load_file'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:365:in `block in require_or_load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:13:in `loading'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in `load_interlock'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:348:in `require_or_load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:502:in `load_missing_constant'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:193:in `const_missing'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/inflector/methods.rb:283:in `const_get'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/inflector/methods.rb:283:in `block in constantize'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/inflector/methods.rb:281:in `each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/inflector/methods.rb:281:in `inject'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/inflector/methods.rb:281:in `constantize'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:574:in `get'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:605:in `constantize'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise.rb:316:in `get'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/mapping.rb:83:in `to'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/mapping.rb:78:in `modules'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/mapping.rb:95:in `routes'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/mapping.rb:162:in `default_used_route'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/mapping.rb:72:in `initialize'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise.rb:346:in `new'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise.rb:346:in `add_mapping'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/rails/routes.rb:243:in `block in devise_for'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/rails/routes.rb:242:in `each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/devise-4.4.3/lib/devise/rails/routes.rb:242:in `devise_for'
    from /Users/ktg/privates/my_projects/config/routes.rb:8:in `block in <top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:414:in `draw'
    from /Users/ktg/privates/my_projects/config/routes.rb:1:in `<top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `block in load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `load'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:57:in `block in load_paths'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:57:in `each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:57:in `load_paths'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:20:in `reload!'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:43:in `block in updater'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/file_update_checker.rb:83:in `execute'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:44:in `updater'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/routes_reloader.rb:33:in `execute_if_updated'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `call'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
    from /Users/ktg/privates/my_projects/config/environment.rb:5:in `<top (required)>'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /Users/ktg/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from -e:1:in `<main>'

application.rb에 있는 하단 내용을 삭제 합니다.

config.active_record.raise_in_transactional_callbacks = true

하단 내용 참고

https://stackoverflow.com/questions/37464966/what-causes-deprecation-warning-activerecordbase-raise-in-transactional-callb

Coffeescript Error

이제 레일즈 서버를 실행하고 접속해봅니다.

$ rails s
$ curl localhost:3000

Output

=> Booting Puma
=> Rails 5.2.0 application starting in development
=> Run `rails server -h` for more startup options
[32087] Puma starting in cluster mode...
[32087] * Version 3.11.4 (ruby 2.5.1-p57), codename: Love Song
[32087] * Min threads: 5, max threads: 5
[32087] * Environment: development
[32087] * Process workers: 2
[32087] * Preloading application
[32087] * Listening on tcp://0.0.0.0:3000
[32087] Use Ctrl-C to stop
[32087] - Worker 0 (pid: 32090) booted, phase: 0
[32087] - Worker 1 (pid: 32091) booted, phase: 0
Started GET "/" for 127.0.0.1 at 2018-05-29 23:37:10 +0900
   (0.4ms)  SET  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
   (0.3ms)  SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
Processing by MainController#index as HTML
Completed 401 Unauthorized in 14ms (ActiveRecord: 0.0ms)


Started GET "/login" for 127.0.0.1 at 2018-05-29 23:37:10 +0900
Processing by Devise::SessionsController#new as HTML
  Rendering devise/sessions/new.html.erb within layouts/application
  Rendered devise/shared/_links.html.erb (1.0ms)
  Rendered devise/sessions/new.html.erb within layouts/application (16.6ms)
Completed 500 Internal Server Error in 6804ms (ActiveRecord: 1.4ms)



LoadError (cannot load such file -- coffee_script):

app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___3099409563303512009_70257788966240'

NameError: uninitialized constant Mime::HTML
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:58:in `acceptable_content_type?'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:36:in `block in call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `catch'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/rack/logger.rb:38:in `call_app'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/rack/logger.rb:26:in `block in call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/tagged_logging.rb:71:in `block in tagged'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/tagged_logging.rb:28:in `tagged'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/tagged_logging.rb:71:in `tagged'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/rack/logger.rb:26:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/request_id.rb:27:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/executor.rb:14:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/static.rb:127:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-cors-1.0.2/lib/rack/cors.rb:97:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/engine.rb:524:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/configuration.rb:225:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/server.rb:632:in `handle_request'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/server.rb:446:in `process_client'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/server.rb:306:in `block in run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/assets/css/main.min.css" for 127.0.0.1 at 2018-05-29 23:37:18 +0900

ActionController::RoutingError (No route matches [GET] "/assets/css/main.min.css"):

actionpack (5.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.0) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.0) lib/rails/rack/logger.rb:26:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
railties (5.2.0) lib/rails/engine.rb:524:in `call'
puma (3.11.4) lib/puma/configuration.rb:225:in `call'
puma (3.11.4) lib/puma/server.rb:632:in `handle_request'
puma (3.11.4) lib/puma/server.rb:446:in `process_client'
puma (3.11.4) lib/puma/server.rb:306:in `block in run'
puma (3.11.4) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

NameError: uninitialized constant Mime::HTML
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:58:in `acceptable_content_type?'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:36:in `block in call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `catch'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/rack/logger.rb:38:in `call_app'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/rack/logger.rb:26:in `block in call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/tagged_logging.rb:71:in `block in tagged'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/tagged_logging.rb:28:in `tagged'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/tagged_logging.rb:71:in `tagged'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/rack/logger.rb:26:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/request_id.rb:27:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.0/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/executor.rb:14:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.0/lib/action_dispatch/middleware/static.rb:127:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/rack-cors-1.0.2/lib/rack/cors.rb:97:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/railties-5.2.0/lib/rails/engine.rb:524:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/configuration.rb:225:in `call'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/server.rb:632:in `handle_request'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/server.rb:446:in `process_client'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/server.rb:306:in `block in run'
    from /Users/ktg/.rvm/gems/ruby-2.5.1/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

엄청나게 긴 에러를 만납니다.
원인을 찾아보니, 원인은 단순합니다.
사용하지 않는 coffeescript 파일들이 프로젝트에 존재하고 있었습니다.

아래 명령으로 확인후 삭제 해줍니다.

$ find . -name "*.coffee"

그러고도 에러가 난다면 **cache*** 문제입니다.

cache 를 삭제해줍니다.

$ rake tmp:cache:clear

관련 내용은 여기서 확인 가능합니다.

web-console 문제

위의 에러에서

NameError: uninitialized constant Mime::HTML
이런 에러가 있는데 이건 web-console 버전 문제였습니다..

web-console을 업데이트 해줍니다.

$ bundle update web-console

다시 실행합니다.

결론


여기까지 제가 해결한 문제였습니다.

AWS t2 tier 이용하기 – swap memory

AWS t2 tier 이용하기 – swap memory

문제점

회사에서 Aws t2.small 티어를 이용하던 중에 Alertmanager 로 부터 아래의 alert message 를 받게 되었습니다.

메시지를 확인해보니 제가 회사에서 관리하는 docker 모듈들을 간단히 web에 확인해보고자 설치한 Portainer | Simple management UI for Docker 인스턴스가 Memory swap 용량을 절반 이상을 사용했다고 합니다.

Instance 에 접속해서 memory 를 확인합니다.

$ free -mh

Swap memory 가 1M? 2M? 정도 밖게 되지 않습니다.

그래서 아무도 사용하지 않는(..) portainer 인스턴스에서 괴상하게 얼럿이 날라왔던 것입니다.

해결책

해결을 위해 관련 정보를 찾아봅니다.

Adding swap space to an EC2 Amazon Linux instance – PTS: Technical Consulting

위의 포스팅 대로 따라하면 손쉽게 스왑메모리를 확보할 수 있습니다…만,

전 간단하게 불필요한걸로 보이는 명령은 빼고 아래 명령만 실행했습니다.

sudo swapoff -a
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=1024   
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
sudo swapon -s

free -mh

간단히 스왑을 끄고, 1기가 스왑 파일 할당후에 스왑 적용 했습니다.

제가 사용한 인스턴스는 t2.small 로 1G의 스왑메모리가 적당하다고 판단해서 만들었습니다.

용량은 각자 지정하면 될 듯 합니다.

결론

  • aws t2 tier 의 인스턴스를 사용할 경우 OOM이 나은 선택일 경우는 그냥 쿨하게 더 높은 인스턴스를 사용하자.
  • 느려져도 관계없이 잘 돌아가기만 해도 되는 서비스라면, t2 사용시 swap 메모리를 항상 조정해주자.

HTML
tag self closing issue

Rails 개발 중 의문의 버그

환경

  • Ruby 2.3.4
  • Rails 5.0.4

증상

<div class="modal fade">
...
<%= form_tag "/videos", method: 'get' do %>
  <%= select_tag(:environment_id, options_for_select(['dev','prod']), class: "form-control", include_blank: true, onchange: "this.form.submit();") %>
<% end %>
...
</div>

이런 형태의 erb를 만들어서 view 안에서 render 로 view 를 부분적으로 생성했습니다.

그런데!

<form method=“get”  accept-charset="UTF-8"></form>
<select ...

이런 식으로 form tag 가 지맘대로 닫히고 그 아래에 select 태그가 생겼습니다.

이것 때문에 onchange 의 스크립트에서 문제가 생겼습니다.

해결

구글링을 하던 중..

루비 포럼에서 Form tag self closing 이라는 글을 발견했습니다.

참고: form tag is self-closing before input fields (HAML generator used)

문제는 이것
That's not legal markup. Either wrap the form around the entire table or put it completely inside a cell.

<td> 태그안으로 modal view를 넣어서 해결했습니다.

[Vuejs] Node 버전 업데이트시 `deprecated` message

[Vuejs] Node 버전 업데이트시 deprecated message

상황

Vuejs 프로젝트를 작성 중에 배포를 위해 node 프로젝트를Dockerizing 하는 내용을 검색하기 위해 알아보았습니다.

그러다가 Dockerhub for nodejs 를 들어가게 되었더니….
두둥!!

제가 쓰는 nodejs 버전이 없네요? (7.8.0)

그래서 이 참에 최신버전(당시 8.9.0)으로 nodejs를 올리기로 결정했습니다.

맥용 nodejs이 사이트에서 다운로드 | Node.js 받으시고 그냥 덮어 쓰시면 됩니다.

저는 이상하게 크롬에서 자꾸 다운로드가 실패해서 wget 으로 받았습니다.

$ wget https://nodejs.org/dist/v8.9.0/node-v8.9.0.pkg

문제

설치 후에 vuejs 프로젝트에서 npm install을 실행하고 npm run dev를 실행했더니 deprecated 메시지를 발견 했습니다.

“scope” attribute for scoped slots have been deprecated and replaced by "slot-scope"

몰랐는데 이건 또 뭐지? 싶어서 찾아봤더니

Vue 2.5 Scope attribute deprecated replaced by slot-scope · Issue #283 · ratiw/vuetable-2 · GitHub

이런 글이 있네요.

해결

원인은 scope 라는 키워드를 slot-scope 로 바꿔써 써야하는 것이었습니다.

보다 디테일한 내용은
https://kr.vuejs.org/v2/guide/components.html#범위를-가지는-슬롯\

여기서 확인가능합니다.

문서를 보면 위 github의 내용과는 조금 다르게