Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1035 from graphcool/open_source_server
Browse files Browse the repository at this point in the history
Open source Graphcool Server
  • Loading branch information
dpetrick authored Oct 25, 2017
2 parents f2e314d + 8612dc6 commit 9d9dd4c
Show file tree
Hide file tree
Showing 834 changed files with 58,466 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/.buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker kill $(docker ps -q) &> /dev/null
echo "Stopped all old docker containers..."
42 changes: 42 additions & 0 deletions server/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
steps:
- label: ":scala: libs"
command: ./scripts/test.sh libs

- label: ":scala: backend-api-relay"
command: ./scripts/test.sh backend-api-relay

- label: ":scala: backend-api-simple"
command: ./scripts/test.sh backend-api-simple

- label: ":scala: backend-api-system"
command: ./scripts/test.sh backend-api-system

- label: ":scala: backend-api-simple-subscriptions"
command: ./scripts/test.sh backend-api-simple-subscriptions

- label: ":scala: backend-api-subscriptions-websocket"
command: ./scripts/test.sh backend-api-subscriptions-websocket

- label: ":scala: backend-api-fileupload"
command: ./scripts/test.sh backend-api-fileupload

- label: ":scala: backend-api-schema-manager"
command: ./scripts/test.sh backend-api-schema-manager

- label: ":scala: backend-shared"
command: ./scripts/test.sh backend-shared

- label: ":scala: client-shared"
command: ./scripts/test.sh client-shared

- label: ":scala: backend-workers"
command: ./scripts/test.sh backend-workers

- wait

- label: ":sbt: Publish JARs"
command: ./scripts/publish-jars.sh

- label: ":docker: Build"
command: ./scripts/docker-build.sh
branches: master
3 changes: 3 additions & 0 deletions server/.codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
exclude_paths:
- '**Spec.scala'
35 changes: 35 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.DS_Store

*.class
*.log
.coursier
.envrc

.ivy2

# Idea
.idea
.idea_modules

# sbt specific
.sbt
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/

# Scala-IDE specific
.scala_dependencies

.ensime
.ensime_cache

# test files
/schema
/request.json
/docker.env

# buildkite artifacts
buildkite-script-*
1 change: 1 addition & 0 deletions server/.sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-J-XX:MaxMetaspaceSize=2G
3 changes: 3 additions & 0 deletions server/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
style = defaultWithAlign
maxColumn = 160
align = most
10 changes: 10 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Graphcool Server
The Graphcool Server is composed of a GraphQL database, the Realtime Subscriptions API, and an engine enabling asynchronous, event-driven flows using serverless functions.

## Running the tests
1. Make sure to have docker up and running
1. Make sure to make the env variables in `env_example` available, for example with `source env_example`.
1. Start all required dependencies with `docker-compose -f docker-compose/backend-dev.yml up -d --remove-orphans`
1. Run `sbt test`. This will take a few minutes.

If you want to clean up afterwards, make sure to run `docker-compose -f docker-compose/backend-dev.yml down -v --remove-orphans`
1 change: 1 addition & 0 deletions server/backend-api-fileupload/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.13
3 changes: 3 additions & 0 deletions server/backend-api-fileupload/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.4.0")
94 changes: 94 additions & 0 deletions server/backend-api-fileupload/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
akka {
loglevel = INFO
http.server {
parsing.max-uri-length = 50k
parsing.max-header-value-length = 50k
remote-address-header = on
parsing.max-content-length = 250m
request-timeout = 660s
}
http.host-connection-pool {
// see http://doc.akka.io/docs/akka-http/current/scala/http/client-side/pool-overflow.html
// and http://doc.akka.io/docs/akka-http/current/java/http/configuration.html
// These settings are relevant for Region Proxy Synchronous Request Pipeline functions and ProjectSchemaFetcher
max-connections = 64 // default is 4, but we have multiple servers behind lb, so need many connections to single host
max-open-requests = 2048 // default is 32, but we need to handle spikes
}
http.client {
parsing.max-content-length = 50m
}
}

jwtSecret = ${?JWT_SECRET}
schemaManagerEndpoint = ${SCHEMA_MANAGER_ENDPOINT}
schemaManagerSecret = ${SCHEMA_MANAGER_SECRET}
awsAccessKeyId = ${AWS_ACCESS_KEY_ID}
awsSecretAccessKey = ${AWS_SECRET_ACCESS_KEY}
awsAccessKeyId = ${AWS_ACCESS_KEY_ID}
awsSecretAccessKey = ${AWS_SECRET_ACCESS_KEY}
// note: special fileupload AWS credentials required because the file bucket is in a separate aws account
fileuploadAwsAccessKeyId = ${FILEUPLOAD_S3_AWS_ACCESS_KEY_ID}
fileuploadAwsSecretAccessKey = ${FILEUPLOAD_S3_AWS_SECRET_ACCESS_KEY}
awsRegion = ${AWS_REGION}

internal {
dataSourceClass = "slick.jdbc.DriverDataSource"
properties {
url = "jdbc:mysql://"${?SQL_INTERNAL_HOST}":"${?SQL_INTERNAL_PORT}"/"${?SQL_INTERNAL_DATABASE}"?autoReconnect=true&useSSL=false&serverTimeZone=UTC&usePipelineAuth=false"
user = ${?SQL_INTERNAL_USER}
password = ${?SQL_INTERNAL_PASSWORD}
}
numThreads = ${?SQL_INTERNAL_CONNECTION_LIMIT}
connectionTimeout = 5000
}

clientDatabases {
client1 {
master {
connectionInitSql="set names utf8mb4"
dataSourceClass = "slick.jdbc.DriverDataSource"
properties {
url = "jdbc:mysql://"${?SQL_CLIENT_HOST_CLIENT1}":"${?SQL_CLIENT_PORT}"/?autoReconnect=true&useSSL=false&serverTimeZone=UTC&useUnicode=true&characterEncoding=UTF-8&usePipelineAuth=false"
user = ${?SQL_CLIENT_USER}
password = ${?SQL_CLIENT_PASSWORD}
}
numThreads = ${?SQL_CLIENT_CONNECTION_LIMIT}
connectionTimeout = 5000
}
}
}

# test DBs

internalTest {
dataSourceClass = "slick.jdbc.DriverDataSource"
properties {
url = "jdbc:mysql://"${?TEST_SQL_INTERNAL_HOST}":"${?TEST_SQL_INTERNAL_PORT}"/"${?TEST_SQL_INTERNAL_DATABASE}"?autoReconnect=true&useSSL=false&serverTimeZone=UTC&usePipelineAuth=false"
user = ${?TEST_SQL_INTERNAL_USER}
password = ${?TEST_SQL_INTERNAL_PASSWORD}
}
numThreads = ${?TEST_SQL_INTERNAL_CONNECTION_LIMIT}
connectionTimeout = 5000
}

internalTestRoot {
dataSourceClass = "slick.jdbc.DriverDataSource"
properties {
url = "jdbc:mysql://"${?TEST_SQL_INTERNAL_HOST}":"${?TEST_SQL_INTERNAL_PORT}"/?autoReconnect=true&useSSL=false&serverTimeZone=UTC&usePipelineAuth=false"
user = "root"
password = ${?TEST_SQL_INTERNAL_PASSWORD}
}
numThreads = ${?TEST_SQL_INTERNAL_CONNECTION_LIMIT}
connectionTimeout = 5000
}

clientTest {
dataSourceClass = "slick.jdbc.DriverDataSource"
properties {
url = "jdbc:mysql:aurora://"${?TEST_SQL_CLIENT_HOST}":"${?TEST_SQL_CLIENT_PORT}"/?autoReconnect=true&useSSL=false&serverTimeZone=UTC&usePipelineAuth=false"
user = ${?TEST_SQL_CLIENT_USER}
password = ${?TEST_SQL_CLIENT_PASSWORD}
}
numThreads = ${?TEST_SQL_CLIENT_CONNECTION_LIMIT}
connectionTimeout = 5000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><head> <meta charset=utf-8/> <meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui"> <title>Graphcool Playground</title> <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/graphql-playground/middleware-build/static/css/main.css"/> <link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground/middleware-build/favicon.png"/> <script src="//cdn.jsdelivr.net/npm/graphql-playground/middleware-build/static/js/main.js"></script></head><body><div id="root"> <style>body{background-color: rgb(23,42,58); font-family: Open Sans,sans-serif; height: 90vh;}#root{height: 100%; width: 100%; display: flex; align-items: center; justify-content: center;}.loading{font-size: 32px; font-weight: 200; color: rgba(255,255,255,.6); margin-left: 20px;}img{width: 78px; height: 78px;}.title{font-weight: 400;}</style> <img src='//cdn.jsdelivr.net/npm/graphql-playground/middleware-build/logo.png' alt=''> <div class="loading"> Loading <span class="title">GraphQL Playground</span> </div></div><script>window.addEventListener('load', function(event){GraphQLPlayground.init(document.getElementById('root'))})</script></body></html>
13 changes: 13 additions & 0 deletions server/backend-api-fileupload/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<logger name="slick" level="OFF" />
<logger name="com.zaxxer.hikari" level="OFF" />
<!--<logger name="slick.jdbc.JdbcBackend.statement" level="DEBUG" />-->
<!--<logger name="slick.jdbc.StatementInvoker.result" level="DEBUG" />-->
<!--<logger name="slick.jdbc.JdbcBackend.benchmark" level="DEBUG" />-->

<root level="INFO">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
</root>
</configuration>
Loading

0 comments on commit 9d9dd4c

Please sign in to comment.