diff --git a/conf/env.sample b/conf/env.sample deleted file mode 100644 index b6e20e6..0000000 --- a/conf/env.sample +++ /dev/null @@ -1,85 +0,0 @@ -# Sample ENV setup Variables -# Copy this file and update as needed. -# -# $ cp .env.sample .env -# -# Do not include this new file in source control -# - -# Rails Settings -EXPOSED_PORT=3000 -# change this to "production" for production use, otherwise the access token time is very short and forces re-login -RAILS_ENV=development -RAILS_LOG_TO_STDOUT=false -# Log Level options: "INFO" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL" -RAILS_LOG_LEVEL=INFO -#SQS_QUEUE=somequeue -#SQS_QUEUE_LOW_PRIORITY=low_priority_queue -#AWS_REGION=us-west1 -#S3_BACKUP_BUCKET_NAME= - -ACTIVE_JOB_QUEUE_ADAPTER=async - -# Database Settings -DB_PORT=3306 -DB_HOST=127.0.0.1 -DB_DATABASE=standard_notes_db -DB_USERNAME=std_notes_user -# Please change this! -DB_PASSWORD=changeme123 -DB_POOL_SIZE=30 -DB_WAIT_TIMEOUT=180 - -# Secrets -# Use: "bundle exec rake secret" or "openssl rand -hex 64" -# To generate required secret key base below - -SECRET_KEY_BASE=changeme123 -PSEUDO_KEY_PARAMS_KEY=changeme456 - -# Disable user registration -#DISABLE_USER_REGISTRATION=true - -# Datadog -DATADOG_ENABLED=false - -# Mailer settings -SMTP_HOST= -SMTP_PORT= -#SMTP_USERNAME= -#SMTP_PASSWORD= -SMTP_DOMAIN= -# Enalbe STARTTLS -# Empty is disabled -# Any value is enabled -SMTP_STARTTLS= -EMAIL_ATTACHMENT_MAX_SIZE=10485760 - -# SNS EVENTS -#SNS_TOPIC_ARN= - -# (Optional) Database Replication -#DB_REPLICA_HOST= - -# Revisions persistency -REVISIONS_FREQUENCY=300 - -# (Optional) Redis Cache for ephemeral sessions -REDIS_URL=redis://cache:6379 - -# (Optional) Change URLs to Internal DNS -#INTERNAL_DNS_REROUTE_ENABLED=false - -# (Optional) Auth Proxy JWT Secret -#AUTH_JWT_SECRET=changeme123 - -# (Optional) User Management Server - registration emails, subscriptions etc. -#USER_MANAGEMENT_SERVER= - -# Sub-URI -RAILS_RELATIVE_URL_ROOT=/ - -# Public file server -# Empty is disabled -# Any value is enabled -RAILS_SERVE_STATIC_FILES= diff --git a/conf/env_api-gateway.env.sample b/conf/env_api-gateway.env.sample index 9db0d4a..2534cc9 100644 --- a/conf/env_api-gateway.env.sample +++ b/conf/env_api-gateway.env.sample @@ -1,3 +1,6 @@ +Environment="__YNH_NODE_LOAD_PATH__" +PORT="__PORT_API_GATEWAY__" + LOG_LEVEL="info" NODE_ENV="production" diff --git a/conf/env_auth-worker.env.sample b/conf/env_auth-worker.env.sample new file mode 100644 index 0000000..4363022 --- /dev/null +++ b/conf/env_auth-worker.env.sample @@ -0,0 +1,33 @@ +Environment="__YNH_NODE_LOAD_PATH__" +PORT="__PORT_AUTH__" + +LOG_LEVEL="info" +NODE_ENV="production" + +AUTH_JWT_TTL=60000 +JWT_SECRET=__JWT_SECRET__ +LEGACY_JWT_SECRET=__LEGACY_JWT_SECTRET__ + +NEW_RELIC_ENABLED=false +NEW_RELIC_APP_NAME=Auth +NEW_RELIC_NO_CONFIG_FILE=true + +REDIS_EVENTS_CHANNEL="auth-events" + +DISABLE_USER_REGISTRATION=false + +PSEUDO_KEY_PARAMS_KEY=__PSEUDO_KEY_PARAMS_KEY__ + +ACCESS_TOKEN_AGE=5184000 +REFRESH_TOKEN_AGE=31556926 + +MAX_LOGIN_ATTEMPTS=6 +FAILED_LOGIN_LOCKOUT=3600 + +EPHEMERAL_SESSION_AGE=259200 + +# Must be a hex string exactly 32 bytes long +# e.g. feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308 +ENCRYPTION_SERVER_KEY=__ENCRYPTION_SERVER_KEY__ + +SYNCING_SERVER_URL=http://localhost:__PORT_SYNCING_SERVER_JS__ diff --git a/conf/env_auth.env.sample b/conf/env_auth.env.sample index 4009ea1..1928eea 100644 --- a/conf/env_auth.env.sample +++ b/conf/env_auth.env.sample @@ -1,3 +1,6 @@ +Environment="__YNH_NODE_LOAD_PATH__" +PORT="__PORT_AUTH_WORKER__" + LOG_LEVEL="info" NODE_ENV="production" diff --git a/conf/env_syncing-server.env.sample b/conf/env_syncing-server-js-worker.env.sample similarity index 92% rename from conf/env_syncing-server.env.sample rename to conf/env_syncing-server-js-worker.env.sample index baa11f6..dd41d4f 100644 --- a/conf/env_syncing-server.env.sample +++ b/conf/env_syncing-server-js-worker.env.sample @@ -1,3 +1,6 @@ +Environment="__YNH_NODE_LOAD_PATH__" +PORT="__PORT_SYNCING_SERVER_JS__" + LOG_LEVEL="info" NODE_ENV="production" diff --git a/conf/env_syncing-server-js.env.sample b/conf/env_syncing-server-js.env.sample new file mode 100644 index 0000000..dd41d4f --- /dev/null +++ b/conf/env_syncing-server-js.env.sample @@ -0,0 +1,44 @@ +Environment="__YNH_NODE_LOAD_PATH__" +PORT="__PORT_SYNCING_SERVER_JS__" + +LOG_LEVEL="info" +NODE_ENV="production" + +AUTH_JWT_SECRET=__JWT_SECRET__ + +EXPOSED_PORT=__PORT_SYNCING_SERVER_JS__ + +DB_HOST=localhost +DB_REPLICA_HOST=localhost +DB_PORT=3306 +DB_USERNAME=__DB_USER__ +DB_PASSWORD=__DB_PWD__ +DB_DATABASE=__DB_NAME__ +DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration" +DB_MIGRATIONS_PATH=dist/migrations/*.js + +REDIS_URL=redis://localhost:6379/__REDIS_DB__ + +SNS_TOPIC_ARN= +SNS_AWS_REGION= +SQS_QUEUE_URL= +SQS_AWS_REGION= +S3_AWS_REGION= +S3_BACKUP_BUCKET_NAME= + +REDIS_EVENTS_CHANNEL=events + +AUTH_SERVER_URL=http://localhost:__PORT_AUTH__ + +EMAIL_ATTACHMENT_MAX_BYTE_SIZE=10485760 + +REVISIONS_FREQUENCY=300 + +# (Optional) New Relic Setup +NEW_RELIC_ENABLED=false +NEW_RELIC_APP_NAME="Syncing Server JS" +NEW_RELIC_LICENSE_KEY= +NEW_RELIC_NO_CONFIG_FILE=true +NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=false +NEW_RELIC_LOG_ENABLED=false +NEW_RELIC_LOG_LEVEL=info diff --git a/conf/systemd_api-gateway.service b/conf/systemd_api-gateway.service index 78a2c8f..1fed5a1 100644 --- a/conf/systemd_api-gateway.service +++ b/conf/systemd_api-gateway.service @@ -9,9 +9,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/live/api-gateway -Environment="PATH=__ENV_PATH__" -Environment="NODE_ENV=production" -Environment="__YNH_NODE_LOAD_PATH__" +EnvironmentFile=__FINALPATH__/live/api-gateway/.env ExecStart=/usr/bin/yarn start StandardOutput=append:/var/log/__APP__/api-gateway.log StandardError=inherit diff --git a/conf/systemd_auth-worker.service b/conf/systemd_auth-worker.service index b2d79c3..839315f 100644 --- a/conf/systemd_auth-worker.service +++ b/conf/systemd_auth-worker.service @@ -10,9 +10,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/live/auth-worker -Environment="PATH=__ENV_PATH__" -Environment="NODE_ENV=production" -Environment="__YNH_NODE_LOAD_PATH__" +EnvironmentFile=__FINALPATH__/live/auth-worker/.env ExecStart=/usr/bin/yarn worker StandardOutput=append:/var/log/__APP__/auth-worker.log StandardError=inherit diff --git a/conf/systemd_auth.service b/conf/systemd_auth.service index 55f4c59..c6df3e6 100644 --- a/conf/systemd_auth.service +++ b/conf/systemd_auth.service @@ -10,9 +10,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/live/auth -Environment="PATH=__ENV_PATH__" -Environment="NODE_ENV=production" -Environment="__YNH_NODE_LOAD_PATH__" +EnvironmentFile=__FINALPATH__/live/auth/.env ExecStart=/usr/bin/yarn start StandardOutput=append:/var/log/__APP__/auth.log StandardError=inherit diff --git a/conf/systemd_syncing-server-js-worker.service b/conf/systemd_syncing-server-js-worker.service index 7a3fa16..c0af381 100644 --- a/conf/systemd_syncing-server-js-worker.service +++ b/conf/systemd_syncing-server-js-worker.service @@ -10,9 +10,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/live/syncing-server-js-worker -Environment="PATH=__ENV_PATH__" -Environment="NODE_ENV=production" -Environment="__YNH_NODE_LOAD_PATH__" +EnvironmentFile=__FINALPATH__/live/syncing-server-js-worker/.env ExecStart=/usr/bin/yarn worker StandardOutput=append:/var/log/__APP__/syncing-server-js-worker.log StandardError=inherit diff --git a/conf/systemd_syncing-server-js.service b/conf/systemd_syncing-server-js.service index 8d46b80..51e94ba 100644 --- a/conf/systemd_syncing-server-js.service +++ b/conf/systemd_syncing-server-js.service @@ -9,9 +9,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/live/syncing-server-js -Environment="PATH=__ENV_PATH__" -Environment="NODE_ENV=production" -Environment="__YNH_NODE_LOAD_PATH__" +EnvironmentFile=__FINALPATH__/live/syncing-server-js/.env ExecStart=/usr/bin/yarn start StandardOutput=append:/var/log/__APP__/syncing-server-js.log StandardError=append:inherit diff --git a/scripts/install b/scripts/install index 4c6055b..e65b5a1 100755 --- a/scripts/install +++ b/scripts/install @@ -71,7 +71,7 @@ port_syncing_server_js=$(ynh_find_port --port=3000) port_syncing_server_js_worker=$(ynh_find_port --port=$((port_syncing_server_js+1))) port_auth=$(ynh_find_port --port=$((port_syncing_server_js_worker+1))) port_auth_worker=$(ynh_find_port --port=$((port_auth+1))) -port_api_gateway=$(ynh_find_port --port=$((port_autho_worker+1))) +port_api_gateway=$(ynh_find_port --port=$((port_auth_worker+1))) # Open the port ynh_app_setting_set --app=$app --key=port --value=$port_syncing_server_js ynh_app_setting_set --app=$app --key=port --value=$port_syncing_server_js_worker @@ -136,9 +136,11 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Modifying a config file..." --weight=2 -config_syncing_server_js="$final_path/live/syncing-server-js.env" -config_auth="$final_path/live/auth.env" -config_api_gateway="$final_path/live/api-gateway.env" +config_syncing_server_js="$final_path/live/syncing-server-js/.env" +config_syncing_server_js_worker="$final_path/live/syncing-server-js-worker/.env" +config_auth="$final_path/live/auth/.env" +config_auth_worker="$final_path/live/auth-worker/.env" +config_api_gateway="$final_path/live/api-gateway/.env" jwt_sectret=$(ynh_string_random --length=48 | base64) @@ -157,7 +159,9 @@ ynh_app_setting_set --app=$app --key=encryption_server_key --value=$encryption_s #ynh_replace_string --match_string="SMTP_STARTTLS=.*$" --replace_string="SMTP_STARTTLS=" --target_file="$config_file" ynh_add_config --template="env_syncing-server-js.env.sample" --destination="$config_syncing_server_js" +ynh_add_config --template="env_syncing-server-js-worker.env.sample" --destination="$config_syncing_server_js_worker" ynh_add_config --template="env_auth.env.sample" --destination="$config_auth" +ynh_add_config --template="env_auth-worker.env.sample" --destination="$config_auth_worker" ynh_add_config --template="env_api-gateway.env.sample" --destination="$config_api_gateway" #ynh_replace_string --match_string="__MAIL__" --replace_string="$mail" --target_file="$final_path/live/app/mailers/application_mailer.rb" @@ -239,7 +243,9 @@ ynh_script_progression --message="Storing the config file checksum..." --weight= # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$onfig_syncing_server_js" +ynh_store_file_checksum --file="$onfig_syncing_server_js_worker" ynh_store_file_checksum --file="$onfig_auth" +ynh_store_file_checksum --file="$onfig_auth_worker" ynh_store_file_checksum --file="$onfig_api_gateway" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"