diff --git a/backend/.env.dist b/backend/.env.dist index 69b1d6a46..648a2054c 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -1,4 +1,4 @@ -CONFIG_VERSION=v9.2022-07-07 +CONFIG_VERSION=v10.2022-09-20 # Server PORT=4000 @@ -37,6 +37,8 @@ LOGIN_SERVER_KEY=a51ef8ac7ef1abf162fb7a65261acd7a # EMail EMAIL=false +EMAIL_TEST_MODUS=false +EMAIL_TEST_RECEIVER=stage1@gradido.net EMAIL_USERNAME=gradido_email EMAIL_SENDER=info@gradido.net EMAIL_PASSWORD=xxx diff --git a/backend/.env.template b/backend/.env.template index beaa256ef..dddf845dc 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -36,6 +36,8 @@ LOGIN_SERVER_KEY=a51ef8ac7ef1abf162fb7a65261acd7a # EMail EMAIL=$EMAIL +EMAIL_TEST_MODUS=$EMAIL_TEST_MODUS +EMAIL_TEST_RECEIVER=$EMAIL_TEST_RECEIVER EMAIL_USERNAME=$EMAIL_USERNAME EMAIL_SENDER=$EMAIL_SENDER EMAIL_PASSWORD=$EMAIL_PASSWORD diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 7daf0607b..3e6bafd9f 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -17,7 +17,7 @@ const constants = { LOG_LEVEL: process.env.LOG_LEVEL || 'info', CONFIG_VERSION: { DEFAULT: 'DEFAULT', - EXPECTED: 'v9.2022-07-07', + EXPECTED: 'v10.2022-09-20', CURRENT: '', }, } @@ -67,6 +67,8 @@ const loginServer = { const email = { EMAIL: process.env.EMAIL === 'true' || false, + EMAIL_TEST_MODUS: process.env.EMAIL_TEST_MODUS === 'true' || 'false', + EMAIL_TEST_RECEIVER: process.env.EMAIL_TEST_RECEIVER || 'stage1@gradido.net', EMAIL_USERNAME: process.env.EMAIL_USERNAME || 'gradido_email', EMAIL_SENDER: process.env.EMAIL_SENDER || 'info@gradido.net', EMAIL_PASSWORD: process.env.EMAIL_PASSWORD || 'xxx', diff --git a/backend/src/mailer/sendEMail.test.ts b/backend/src/mailer/sendEMail.test.ts index 5746f1ead..a6f4bb62a 100644 --- a/backend/src/mailer/sendEMail.test.ts +++ b/backend/src/mailer/sendEMail.test.ts @@ -73,7 +73,7 @@ describe('sendEMail', () => { it('calls sendMail of transporter', () => { expect((createTransport as jest.Mock).mock.results[0].value.sendMail).toBeCalledWith({ from: `Gradido (nicht antworten) <${CONFIG.EMAIL_SENDER}>`, - to: 'receiver@mail.org', + to: `${CONFIG.EMAIL_TEST_RECEIVER}`, cc: 'support@gradido.net', subject: 'Subject', text: 'Text text text', diff --git a/backend/src/mailer/sendEMail.ts b/backend/src/mailer/sendEMail.ts index 746daa810..00282f232 100644 --- a/backend/src/mailer/sendEMail.ts +++ b/backend/src/mailer/sendEMail.ts @@ -19,6 +19,12 @@ export const sendEMail = async (emailDef: { logger.info(`Emails are disabled via config...`) return false } + if (CONFIG.EMAIL_TEST_MODUS) { + logger.info( + `Testmodus=ON: change receiver from ${emailDef.to} to ${CONFIG.EMAIL_TEST_RECEIVER}`, + ) + emailDef.to = CONFIG.EMAIL_TEST_RECEIVER + } const transporter = createTransport({ host: CONFIG.EMAIL_SMTP_URL, port: Number(CONFIG.EMAIL_SMTP_PORT), diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index a0b294281..d1153cdb6 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -75,6 +75,9 @@ const createServer = async ( logger, }) apollo.applyMiddleware({ app, path: '/' }) + logger.info( + `running with PRODUCTION=${CONFIG.PRODUCTION}, sending EMAIL enabled=${CONFIG.EMAIL} and EMAIL_TEST_MODUS=${CONFIG.EMAIL_TEST_MODUS} ...`, + ) logger.debug('createServer...successful') return { apollo, app, con } } diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index ebb6717e7..b090908e1 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -26,10 +26,11 @@ COMMUNITY_REDEEM_CONTRIBUTION_URL=https://stage1.gradido.net/redeem/CL-{code} COMMUNITY_DESCRIPTION="Gradido Development Stage1 Test Community" # backend -BACKEND_CONFIG_VERSION=v9.2022-07-07 +BACKEND_CONFIG_VERSION=v10.2022-09-20 JWT_EXPIRES_IN=10m GDT_API_URL=https://gdt.gradido.net +ENV_NAME=stage1 TYPEORM_LOGGING_RELATIVE_PATH=../deployment/bare_metal/log/typeorm.backend.log @@ -40,6 +41,8 @@ KLICKTIPP_APIKEY_DE= KLICKTIPP_APIKEY_EN= EMAIL=true +EMAIL_TEST_MODUS=false +EMAIL_TEST_RECEIVER=test_team@gradido.net EMAIL_USERNAME=peter@lustig.de EMAIL_SENDER=peter@lustig.de EMAIL_PASSWORD=1234 diff --git a/deployment/bare_metal/install.sh b/deployment/bare_metal/install.sh index 9366cbc75..ddb2706eb 100755 --- a/deployment/bare_metal/install.sh +++ b/deployment/bare_metal/install.sh @@ -131,6 +131,10 @@ envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/frontend/.env # Configure admin envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/admin/.env.template > $PROJECT_ROOT/admin/.env +# create cronjob to delete yarn output in /tmp +# crontab -e +# hourly job: 0 * * * * find /tmp -name "yarn--*" -cmin +60 -exec rm -r {} \; > /dev/null +# daily job: 0 4 * * * find /tmp -name "yarn--*" -ctime +1 -exec rm -r {} \; > /dev/null # Start gradido # Note: on first startup some errors will occur - nothing serious ./start.sh \ No newline at end of file diff --git a/deployment/bare_metal/setup.md b/deployment/bare_metal/setup.md index f43a3d655..652a0a5ce 100644 --- a/deployment/bare_metal/setup.md +++ b/deployment/bare_metal/setup.md @@ -95,5 +95,13 @@ > cp .env.dist .env > nano .env >> Adjust values accordingly +# Define cronjob to compensate yarn output in /tmp +> yarn creates output in /tmp directory, which must be deleted regularly and will be done per cronjob +> on stage1 a hourly job is necessary by setting the following job in the crontab for the gradido user +> crontab -e opens the crontab in edit-mode and insert the following entry: +> "0 * * * * find /tmp -name "yarn--*" -cmin +60 -exec rm -r {} \; > /dev/null" +> on stage2 a daily job is necessary by setting the following job in the crontab for the gradido user +> crontab -e opens the crontab in edit-mode and insert the following entry: +> "0 4 * * * find /tmp -name "yarn--*" -ctime +1 -exec rm -r {} \; > /dev/null" # TODO the install.sh is not yet ready to run directly - consider to use it as pattern to do it manually > ./install.sh