From 225d14f78acb8e1c1f4e7a4653819973bab05060 Mon Sep 17 00:00:00 2001 From: antonvasyukhin Date: Wed, 17 Apr 2019 14:12:09 +0400 Subject: [PATCH 1/5] initDB set default to true --- core/src/main/scala/codesearch/core/Main.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/codesearch/core/Main.scala b/core/src/main/scala/codesearch/core/Main.scala index 576103c..f576965 100644 --- a/core/src/main/scala/codesearch/core/Main.scala +++ b/core/src/main/scala/codesearch/core/Main.scala @@ -16,7 +16,7 @@ object Main extends IOApp { final case class Params( updatePackages: Boolean = false, downloadMeta: Boolean = false, - initDB: Boolean = false, + initDB: Boolean = true, buildIndex: Boolean = false, limitedCountPackages: Option[Int] = None, lang: String = "all" From 6ea06efbac0dc19cc9fa239fc065cfde0f2140e6 Mon Sep 17 00:00:00 2001 From: antonvasyukhin Date: Wed, 17 Apr 2019 17:33:06 +0400 Subject: [PATCH 2/5] [#255] removed '-i' flag usages --- Makefile | 4 ---- README.md | 1 - core/src/main/scala/codesearch/core/CLI.scala | 4 ---- core/src/main/scala/codesearch/core/Main.scala | 1 - core/src/main/scala/codesearch/core/Program.scala | 2 +- 5 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 5289a62..6857105 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,6 @@ psql: -e PGPASSWORD=postgres \ postgres psql -h postgres -U postgres sourcesdb -# Create tables -.PHONY: tables -tables: - java -jar codesearch-core.jar -i # Destroy Postgres .PHONY: db-kill diff --git a/README.md b/README.md index a6bc2fd..6c064b1 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ Docker installed, you can do this: $ make build # Build the project $ make db # Download and start Postgres (wait a bit after this step) - $ make tables # Create tables $ make serve # Run the server If you head to now, you should see the project diff --git a/core/src/main/scala/codesearch/core/CLI.scala b/core/src/main/scala/codesearch/core/CLI.scala index b2d2354..28e12e8 100644 --- a/core/src/main/scala/codesearch/core/CLI.scala +++ b/core/src/main/scala/codesearch/core/CLI.scala @@ -17,10 +17,6 @@ object CLI { c.copy(downloadMeta = true) } text "update package meta information" - opt[Unit]('i', "init-database") action { (_, c) => - c.copy(initDB = true) - } text "create tables for database" - opt[Unit]('b', "build-index") action { (_, c) => c.copy(buildIndex = true) } text "build index with only latest packages" diff --git a/core/src/main/scala/codesearch/core/Main.scala b/core/src/main/scala/codesearch/core/Main.scala index f576965..968e2eb 100644 --- a/core/src/main/scala/codesearch/core/Main.scala +++ b/core/src/main/scala/codesearch/core/Main.scala @@ -16,7 +16,6 @@ object Main extends IOApp { final case class Params( updatePackages: Boolean = false, downloadMeta: Boolean = false, - initDB: Boolean = true, buildIndex: Boolean = false, limitedCountPackages: Option[Int] = None, lang: String = "all" diff --git a/core/src/main/scala/codesearch/core/Program.scala b/core/src/main/scala/codesearch/core/Program.scala index 514191a..b635a90 100644 --- a/core/src/main/scala/codesearch/core/Program.scala +++ b/core/src/main/scala/codesearch/core/Program.scala @@ -20,7 +20,7 @@ class Program(langReps: Map[String, LangRep[_ <: DefaultTable]], logger: Logger[ logger.info(s"Codesearch-core started for language ${params.lang}") } - _ <- initDb(params).whenA(params.initDB) + _ <- initDb(params) _ <- downloadMeta(params).whenA(params.downloadMeta) _ <- updatePackages(params).whenA(params.updatePackages) _ <- buildIndex(params).whenA(params.buildIndex) From 92e58c64b89f115beb8d257a4f7b8cc3ee8928bb Mon Sep 17 00:00:00 2001 From: antonvasyukhin Date: Thu, 18 Apr 2019 16:21:00 +0400 Subject: [PATCH 3/5] [#255] removed '-i' flag usages in docker files --- README.md | 3 +-- docker/core/Makefile | 5 ----- docker/docker-stack-compose.yml | 3 +-- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6c064b1..a4c2a53 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ You can run Postgres by yourself, but it's better to use Docker. If you have Docker installed, you can do this: $ make build # Build the project - $ make db # Download and start Postgres (wait a bit after this step) $ make serve # Run the server If you head to now, you should see the project @@ -39,7 +38,7 @@ running. The port can be changed: $ make serve port=7000 Note: if you get an error at the `make tables` stage, you probably haven't -waited enough. Do `make db-kill` and start from `make db` again. +waited enough. Do `make db-kill` and start from `make serve` again. ### Indexing packages diff --git a/docker/core/Makefile b/docker/core/Makefile index 5f8831f..0746a33 100644 --- a/docker/core/Makefile +++ b/docker/core/Makefile @@ -1,8 +1,3 @@ -# Create tables -.PHONY: tables -tables: - java -Dconfig.resource=production.conf -jar codesearch-core.jar -i - # Download package index. Acceptable values: {haskell, rust, ruby, javascript} download-%: java -Dconfig.resource=production.conf -jar codesearch-core.jar -d -l "$*" diff --git a/docker/docker-stack-compose.yml b/docker/docker-stack-compose.yml index babb295..9625486 100644 --- a/docker/docker-stack-compose.yml +++ b/docker/docker-stack-compose.yml @@ -46,8 +46,7 @@ services: - /mnt/vol/index:/index - /mnt/vol/logs:/logs command: > - sh -c "./wait-for postgres:5432 -- make tables && \ - make download-haskell update-haskell index-haskell && \ + sh -c "./wait-for postgres:5432 -- make download-haskell update-haskell index-haskell && \ make download-rust update-rust index-rust && \ make download-ruby update-ruby index-ruby" networks: From 8548aa7749d23daf4888f45db5aabf6d6716dbaa Mon Sep 17 00:00:00 2001 From: antonvasyukhin Date: Thu, 18 Apr 2019 17:59:36 +0400 Subject: [PATCH 4/5] [#255] fixed Readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a4c2a53..4fc5536 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ You can run Postgres by yourself, but it's better to use Docker. If you have Docker installed, you can do this: $ make build # Build the project + $ make db # Download and start Postgres (wait a bit after this step) $ make serve # Run the server If you head to now, you should see the project @@ -37,7 +38,7 @@ running. The port can be changed: $ make serve port=7000 -Note: if you get an error at the `make tables` stage, you probably haven't +Note: if you get an error at the `make serve` stage, you probably haven't waited enough. Do `make db-kill` and start from `make serve` again. ### Indexing packages From 395032f15762b81e4da04a775d20221e79a6b238 Mon Sep 17 00:00:00 2001 From: antonvasyukhin Date: Thu, 23 May 2019 17:25:31 +0400 Subject: [PATCH 5/5] [#255] fixed Readme and compose.yml --- docker/README.MD | 19 ++++--------------- docker/docker-stack-compose.yml | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/docker/README.MD b/docker/README.MD index 928c461..0c804b6 100644 --- a/docker/README.MD +++ b/docker/README.MD @@ -23,14 +23,6 @@ docker run -d -p 5432:5432 \ --name codesearch-db postgres ``` -# Create tables - -``` -docker run -d \ - --link codesearch-db:postgres \ - quay.io/aelve/codesearch-core make tables -``` - # Download packages meta-information (e.g. Haskell) ``` @@ -86,14 +78,11 @@ docker run -p 80:80 -d \ -e JAVA_OPTS="-Dplay.filters.hosts.allowed.1=codesearch.aelve.com -Dplay.filters.hosts.allowed.2=cloud.digitalocean.com"\ quay.io/aelve/codesearch-web-server make serve ``` -# Start the core service with all tasks (tables, download, update, index) for all languages via docker-compose +# Start the core service with all tasks (tables, download, update, index), server and database services for all languages via docker swarm ``` -docker-compose -f docker-compose-core up -d -``` - -# Start the server and database services via docker-compose +mkdir ./{portainer/data,postgresql,data,index,logs}` +docker stack deploy —with-registry-auth -c docker-stack-compose.yml codesearch ``` -docker-compose -f docker-compose-server up -d -``` \ No newline at end of file + diff --git a/docker/docker-stack-compose.yml b/docker/docker-stack-compose.yml index 9625486..851fb26 100644 --- a/docker/docker-stack-compose.yml +++ b/docker/docker-stack-compose.yml @@ -46,7 +46,7 @@ services: - /mnt/vol/index:/index - /mnt/vol/logs:/logs command: > - sh -c "./wait-for postgres:5432 -- make download-haskell update-haskell index-haskell && \ + sh -c "./wait-for codesearch_postgres:5432 -- make download-haskell update-haskell index-haskell && \ make download-rust update-rust index-rust && \ make download-ruby update-ruby index-ruby" networks: