diff options
author | neoninteger | 2019-06-21 23:18:01 +0930 |
---|---|---|
committer | neoninteger | 2019-06-21 23:18:01 +0930 |
commit | e0603e7eaf3910bb0c884b03118448a8fb736b1a (patch) | |
tree | dfa05e6f16218911cfe881e970e54432ac4b22c1 | |
parent | cbc8cb171b9c6c1138124c474266046f242ceeff (diff) | |
download | aur-e0603e7eaf3910bb0c884b03118448a8fb736b1a.tar.gz |
Move core/server configuration into separate configuration files
* For the core-rs tests, this is simply copying a pre-made file instead of
using sed to patch the template configuration.
* For the server, this is a little bit harder. The server does not support
loading a custom configuration from anywhere on the system, so I copy all of
the server's JavaScript files into a directory within $srcdir, copy the
custom configuration and then launch the server from within $srcdir.
* This has the benefit of ensuring that the servers are running with a fully
custom configuration, rather than using exported variables and sed patches
against a user-controlled config.
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 42 | ||||
-rw-r--r-- | config-client.yaml | 60 | ||||
-rw-r--r-- | config-server.yaml | 66 |
4 files changed, 157 insertions, 15 deletions
@@ -11,8 +11,12 @@ pkgbase = turtl-core-rs depends = libsodium depends = openssl-1.0 source = https://github.com/turtl/core-rs/archive/774fa361d021d9ef5237d32d09515ab7b2a32ad2.tar.gz + source = config-client.yaml + source = config-server.yaml source = vars.mk sha256sums = 71c1caf3aeb6245040abb0ee063b574dd6ece6314c60edabbe4299a11df49b68 + sha256sums = f5400e9c80c935915212e818f05eab8d3d542a54ed89e153c20a6c0fa00d8e1a + sha256sums = ef42f08759af7ce12a06ba168877e74835e1bcdc2c4dca3aea9435b5983961e2 sha256sums = 8dd67ffa28f833baa88c57ecabcc0c5e020d53b5a5516034478a0883be29193d pkgname = turtl-core-rs @@ -16,8 +16,12 @@ checkdepends=("turtl-server") _commithash="774fa361d021d9ef5237d32d09515ab7b2a32ad2" source=("https://github.com/turtl/core-rs/archive/${_commithash}.tar.gz" + "config-client.yaml" + "config-server.yaml" "vars.mk") sha256sums=("71c1caf3aeb6245040abb0ee063b574dd6ece6314c60edabbe4299a11df49b68" + "f5400e9c80c935915212e818f05eab8d3d542a54ed89e153c20a6c0fa00d8e1a" + "ef42f08759af7ce12a06ba168877e74835e1bcdc2c4dca3aea9435b5983961e2" "8dd67ffa28f833baa88c57ecabcc0c5e020d53b5a5516034478a0883be29193d") prepare() { @@ -31,18 +35,17 @@ build() { check() { cd "core-rs-${_commithash}" - export TURTL_DB_CONNSTR="postgres://turtl:turtl@localhost:5432/turtl" - export TURTL_UPLOADS_LOCAL="$PWD/turtl-uploads" log() { echo -e " $(tput setaf 4)$(tput bold)->$(tput sgr0) $(tput bold)$@$(tput sgr0)" } - init_dirs() { - mkdir turtl-db turtl-uploads - } - init_database() { + log "Creating directories and copying configuration files..." + mkdir turtl-db turtl-server turtl-server/config turtl-uploads + cp ../config-client.yaml config.yaml + cp ../config-server.yaml turtl-server/config/config.yaml + log "Initializing PostgreSQL database cluster..." initdb -D turtl-db -A trust @@ -51,20 +54,30 @@ check() { } configure_turtl_server() { + log "Copying Turtl server files..." + cd turtl-server + cp -r /usr/share/webapps/turtl/controllers controllers + cp -r /usr/share/webapps/turtl/helpers helpers + cp -r /usr/share/webapps/turtl/models models + cp -r /usr/share/webapps/turtl/node_modules node_modules + cp -r /usr/share/webapps/turtl/scripts scripts + cp -r /usr/share/webapps/turtl/tools tools + cp /usr/share/webapps/turtl/server.js server.js + log "Configuring database for Turtl server..." psql -h /tmp -d postgres -c "CREATE USER turtl WITH PASSWORD 'turtl'" psql -h /tmp -d postgres -c "CREATE DATABASE turtl" - bash -c "cd /usr/share/webapps/turtl && scripts/init-db.sh" - bash -c "cd /usr/share/webapps/turtl && node tools/populate-test-data.js" + scripts/init-db.sh + node tools/populate-test-data.js log "Starting Turtl server..." - node /usr/share/webapps/turtl/server.js & + node server.js & sleep 2 + cd .. } run_tests() { log "Running tests..." - sed '/^ endpoint: /c\ endpoint: ""' config.yaml.default > config.yaml make test-st } @@ -74,26 +87,25 @@ check() { } stop_database() { + cd "$srcdir/core-rs-${_commithash}" log "Stopping PostgreSQL server..." pg_ctl stop -D turtl-db } remove_dirs() { log "Cleaning up..." - rm -rf turtl-db turtl-uploads config.yaml + rm -rf turtl-db turtl-server turtl-uploads config.yaml } - init_dirs - trap "remove_dirs" ERR init_database trap - ERR - trap "stop_database && remove_dirs" ERR + trap "stop_database; remove_dirs" ERR configure_turtl_server trap - ERR - trap "stop_turtl_server && stop_database && remove_dirs" ERR + trap "stop_turtl_server; stop_database; remove_dirs" ERR run_tests trap - ERR diff --git a/config-client.yaml b/config-client.yaml new file mode 100644 index 000000000000..7344591fd8c6 --- /dev/null +++ b/config-client.yaml @@ -0,0 +1,60 @@ +--- +# set to `true` if you want errors to be wrapped in an object that includes the +# file/line number. nice for testing, probably annoying when actually using the +# core +wrap_errors: false + +messaging: + # the channel our request/response dialog happens on + reqres: "inproc://turtl-req" + # the channel used to send events from the core to the UI + events: "inproc://turtl-events" + # if true, the reqres channel responses will vary by the message id. so if you + # set a message id of 53 and this is `true`, and messaging.reqres is + # "turtl-req" then the response will come back on the channel "turtl-req:53" + # + # if this is false, the responses will come back on "turtl-req" and each + # response message will have a message id you can use to match. + reqres_append_mid: false + +# override w/ runtime config! on desktop this should be a subfolder in the user +# folder. in android it should be the location of the app's data folder. +data_folder: '/tmp/turtl' + +# logging configuration +logging: + # the log level (ignore all messages with a log level lower than this) + level: 'info' + # the file to log to. if missing, logging will just be stdout + #file: 'core.log' + # log rotation, only applies if `logging.file` is set + rotation: + keep: 3 + size: 1048576 + +api: + endpoint: "http://localhost:8181" + # this should be set by the client loading the core. standard format is + # <platform>/<version>, like "android/0.7.0" + client_version_string: 'core' + # point this at a v0.6 api (the old lisp server) if you want to enable + # migration from the old system to the new. + #v6: + #endpoint: "https://api.turtlapp.com/v2" + +sync: + enable_incoming: true + enable_outgoing: true + enable_files_incoming: true + enable_files_outgoing: true + poll_timeout: 25 + +# configuration integration tests +integration_tests: + data_folder: /tmp/turtl/integration + login: + username: testdata@turtlapp.com + password: omgitsatest + v6_login: + username: 'duck duck' + password: 'juice' diff --git a/config-server.yaml b/config-server.yaml new file mode 100644 index 000000000000..1f42897789bc --- /dev/null +++ b/config-server.yaml @@ -0,0 +1,66 @@ +--- +server: + # Per default, turtl will listen on all IP addresses + # You can choose the IP it will use with this parameter + host: '127.0.0.1' + port: 8181 + +db: + connstr: 'postgres://turtl:turtl@127.0.0.1:5432/turtl' + pool: 24 + +loglevel: 'info' + +app: + # ALWAYS false in production. Always. + # Set to 'I UNDERSTAND THIS VIOLATES THE PRIVACY OF MY USERS' to enable + enable_bookmarker_proxy: false + # no trailing slash + api_url: 'http://127.0.0.1:8181' + www_url: 'https://turtlapp.com' + emails: + admin: 'admin@turtlapp.com' + info: 'Turtl <info@turtlapp.com>' + invites: 'invites@turtlapp.com' + # TODO: replace this with a long, unique value. seriously. write down a dream + # you had, or the short story you came up with during your creative writing + # class in your freshmen year of college. have fun with it. + secure_hash_salt: "Plaque is a figment of the liberal media and the dental industry to scare you into buying useless appliances and pastes. Now, I've read the arguments on both sides and I haven't found any evidence yet to support the need to brush your teeth. Ever." + # set to true if you think it's ok to SEND invites if you have not confirmed + # your account. great for testing, not so great for production. but what do + # i know... + allow_unconfirmed_invites: false + +sync: + # how many sync records can a client send at a time? it's a good idea to have + # a limit here, lest a rogue client flood the server with sync items + max_bulk_sync_records: 32 + +plugins: + plugin_location: '/usr/share/webapps/turtl/plugins' + # each key here corresponds to a folder name in the plugins folder, so `email` + # below would be a plugin at usr/share/webapps/turtl/plugins/email (see the + # example-plugins/ folder for an email plugin you can use) + email: + enabled: false + endpoint: 'smtps://user:password@smtp.gmail.com/?pool=true' + defaults: {} + +uploads: + # if set to a path, files will be uploaded to the local filesystem instead of + # S3. otherwise, set to false + local: '../turtl-uploads' + # if true, downloading local files will be proxied through the turtl server. + # this avoids needing to set up any CORS config in your favorite webserver, + # but may slightly affect performance on high-demand servers. + local_proxy: true + # if local_proxy is false, this is should be the url path the uploaded files + # are publicly available on + url: 'http://api.turtl.dev/uploads' + +s3: + token: 'IHADAPETSNAKEBUTHEDIEDNOOOOO' + secret: '' + bucket: '' + endpoint: 'https://s3.amazonaws.com' + pathstyle: false |