Skip to content

Commit

Permalink
Merge pull request #15 from showwin/update_for_2020
Browse files Browse the repository at this point in the history
OSやmiddleware、言語のバージョンをアップデート
  • Loading branch information
showwin authored Aug 29, 2020
2 parents 24a2109 + 78c654d commit f8a50aa
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ ISUCONは3人チームで取り組むことを基準に課題が作られてい

## 問題詳細
* マニュアル: [ISHOCON1マニュアル](https://github.com/showwin/ISHOCON1/blob/master/doc/manual.md)
* AMI: `ami-03134665`
* インスタンスタイプ: `c4.xlarge`
* AMI: `ami-044fa950c36d5a250`
* インスタンスタイプ: `c5.xlarge`
* 参考実装言語: Ruby, Go, Python, Crystal(by [@Goryudyuma](https://github.com/Goryudyuma)), Scala(by [@Goryudyuma](https://github.com/Goryudyuma))
* 推奨実施時間: 1人で8時間

Expand Down
2 changes: 1 addition & 1 deletion admin/insert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def config
host: ENV['ISHOCON1_DB_HOST'] || 'localhost',
port: ENV['ISHOCON1_DB_PORT'] && ENV['ISHOCON1_DB_PORT'].to_i,
username: ENV['ISHOCON1_DB_USER'] || 'root',
password: ENV['ISHOCON1_DB_PASSWORD'],
password: ENV['ISHOCON1_DB_PASSWORD'] || 'ishocon1',,
database: ENV['ISHOCON1_DB_NAME'] || 'ishocon1'
}
}
Expand Down
28 changes: 13 additions & 15 deletions doc/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

## インスタンスの作成
AWSのイメージのみ作成しました。
* AMI: ami-03134665
* Instance Type: c4.xlarge
* AMI: ami-044fa950c36d5a250
* Instance Type: c5.xlarge
* EBS Optimization: なし
* Root Volume: 8GB, Magnetic

要望があればGCPでもイメージを作成するかもしれません。

参考画像
* 8GB, Magnetic を選択してください。
![](https://raw.githubusercontent.com/showwin/ISHOCON1/master/doc/images/instance1.png)
Expand All @@ -25,7 +23,7 @@ AWSのイメージのみ作成しました。
### インスタンスにログインする
例:
```
$ ssh -i ~/.ssh/your_private_key.pem ec2-user@xx.xx.xx.xx
$ ssh -i ~/.ssh/your_private_key.pem ubuntu@xx.xx.xx.xx
```

### ishocon ユーザに切り替える
Expand All @@ -37,7 +35,6 @@ $ sudo su - ishocon
$ ls
benchmark #ベンチマーカー
db_init.sh #DBの初期化スクリプト(後で説明)
init #DB初期化に必要なスクリプト(中身は変更しないでください)
webapp #最適化するアプリケーション
```

Expand All @@ -62,21 +59,22 @@ $ go build -o webapp *.go
$ ./webapp
```

#### Scala の場合
```
$ cd ~/webapp/scala/ishocon1
$ sbt
> ~;jetty:stop;jetty:start
```

#### Crystal の場合
```
# メンテナンスされておらず動きません
$ cd ~/webapp/crystal
$ shards install
$ crystal build app.cr
$ ./app
```

#### Scala の場合
```
$ cd ~/webapp/scala
$ sbt
> ~;jetty:stop;jetty:start
```

これでブラウザからアプリケーションが見れるようになるので、IPアドレスにアクセスしてみましょう。

**トップページ**
Expand All @@ -102,9 +100,9 @@ $ ./benchmark --workload 3
* 並列度が高い場合は1分以上経っても終了しない場合がありますが、スコアには影響ありません。

## MySQL
3306 番ポートで MySQL(5.5) が起動しています。初期状態では以下のユーザが設定されています。
3306 番ポートで MySQL(8.0) が起動しています。初期状態では以下のユーザが設定されています。
* ユーザ名: ishocon, パスワード: ishocon
* ユーザ名: root, パスワードなし
* ユーザ名: root, パスワード: ishocon1

別のバージョンのMySQLに変更することも可能です。
その場合、初期データの挿入は
Expand Down
5 changes: 3 additions & 2 deletions webapp/crystal/shard.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name:
name:
version: 0.1.0

# authors:
# - name <[email protected]>

# description: |
# Short description of
# Short description of

# dependencies:
# pg:
Expand All @@ -22,6 +22,7 @@ version: 0.1.0
dependencies:
mysql:
github: crystal-lang/crystal-mysql
version: 0.8.0
kemal:
github: kemalcr/kemal
kemal-session:
Expand Down
6 changes: 3 additions & 3 deletions webapp/crystal/user.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class User
end

def buy_product(pid : String)
Database.exec "INSERT INTO histories (product_id, user_id, created_at) VALUES (?, ?, ?)", pid, @id, Time.now
Database.exec "INSERT INTO histories (product_id, user_id, created_at) VALUES (?, ?, ?)", pid, @id, Time.local
end

def create_comment(pid : String, content : String)
Database.exec "INSERT INTO comments (product_id, user_id, content, created_at) VALUES (?, ?, ?, ?)", pid, @id, content, Time.now
Database.exec "INSERT INTO comments (product_id, user_id, content, created_at) VALUES (?, ?, ?, ?)", pid, @id, content, Time.local
end

def update_last_login
Database.exec "UPDATE users SET last_login = ? WHERE id = ?", Time.now, @id
Database.exec "UPDATE users SET last_login = ? WHERE id = ?", Time.local, @id
end
end

Expand Down
2 changes: 1 addition & 1 deletion webapp/python/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.1
3.8.5
2 changes: 1 addition & 1 deletion webapp/ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

gem 'sinatra'
gem 'mysql2', '0.3.18'
gem 'mysql2', '0.5.3'
gem 'mysql2-cs-bind'
gem 'erubis'
gem 'unicorn'
Expand Down
37 changes: 19 additions & 18 deletions webapp/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ GEM
remote: https://rubygems.org/
specs:
erubis (2.7.0)
foreman (0.78.0)
thor (~> 0.19.1)
kgio (2.10.0)
mysql2 (0.3.18)
mysql2-cs-bind (0.0.6)
foreman (0.87.2)
kgio (2.11.3)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
mysql2-cs-bind (0.0.7)
mysql2
rack (1.6.4)
rack-protection (1.5.3)
rack (2.2.3)
rack-protection (2.0.8.1)
rack
raindrops (0.15.0)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
thor (0.19.1)
tilt (2.0.1)
unicorn (5.0.0)
raindrops (0.19.1)
ruby2_keywords (0.0.2)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
tilt (2.0.10)
unicorn (5.6.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)

PLATFORMS
Expand All @@ -29,10 +30,10 @@ PLATFORMS
DEPENDENCIES
erubis
foreman
mysql2 (= 0.3.18)
mysql2 (= 0.5.3)
mysql2-cs-bind
sinatra
unicorn

BUNDLED WITH
1.10.6
2.1.4
2 changes: 1 addition & 1 deletion webapp/scala/ishocon1/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name := "ishocon1"

version := "1.0"

scalaVersion := "2.12.6"
scalaVersion := "2.11.12"

resolvers += Classpaths.typesafeReleases

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class ishocon1Servlet extends ScalatraServlet with FormSupport with I18nSupport
implicit val getCommentWithWriterResult = GetResult(r => CommentWithWriter(Comment(r.nextInt, r.nextInt, r.nextInt, r.nextString, r.nextTimestamp), r.nextString))

val dbType = "mysql"
val dbHost = "localhost"
val dbHost = sys.env.getOrElse("ISHOCON1_DB_HOST", "localhost")
val dbPort = 3306
val dbUser = sys.env.getOrElse("ISHOCON1_DB_NAME", "ishocon")
val dbPassword = sys.env.getOrElse("ISHOCON1_DB_NAME", "ishocon")
val dbUser = sys.env.getOrElse("ISHOCON1_DB_USER", "ishocon")
val dbPassword = sys.env.getOrElse("ISHOCON1_DB_PASSWORD", "ishocon")
val dbName = sys.env.getOrElse("ISHOCON1_DB_NAME", "ishocon1")
val db = Database.forURL(
"jdbc:%s://%s:%d/%s?characterEncoding=UTF-8&useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC".format(dbType, dbHost, dbPort, dbName),
"jdbc:%s://%s:%d/%s?characterEncoding=UTF-8&useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&allowPublicKeyRetrieval=true".format(dbType, dbHost, dbPort, dbName),
driver = "com.mysql.cj.jdbc.Driver",
user = dbUser,
password = dbPassword)
Expand Down

0 comments on commit f8a50aa

Please sign in to comment.