Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sam/Deployment Fixes #29

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Sam/Deployment Fixes #29

wants to merge 6 commits into from

Conversation

samholmes
Copy link
Contributor

@samholmes samholmes commented May 20, 2021

This is a draft until successfully testing on a new test droplet

@samholmes samholmes marked this pull request as draft May 20, 2021 05:49
@samholmes samholmes force-pushed the sam/deployment-fixes branch from 6817af3 to 5660cf8 Compare May 21, 2021 21:10
samholmes added 2 commits June 1, 2021 15:35
Remove unused config fields and parameterize config with optional ENV.
@samholmes samholmes force-pushed the sam/deployment-fixes branch from 5660cf8 to b2c00d2 Compare June 1, 2021 22:37
samholmes added 2 commits June 2, 2021 14:49
Errors caught from main that are not handled should be logged and the
process should be exited.
Use pino and pino-pretty for fast and simple logging. Use an appropriate
log level for exceptions.
if (!/^\d+(?:.\d+)$/.test(numStr)) {
throw TypeError('Expected number string')
}
return numStr
Copy link
Contributor

@swansontec swansontec Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should do it as:

const clean = Number(asString(raw))
if (isNaN(clean)) throw new TypeError('Expected number string')
return clean

That way the result is a proper number. When I added @types/express to the repo, this string turned into a type error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our discussion: no need for the change because type transformation is handled outside of the cleaner in this context (line 39 for httpPort)

Comment on lines +33 to +42
// Couch
couchDbFullpath: asOptional(
asString,
`http://${env.COUCH_USERNAME}:${env.COUCH_PASSWORD}@${env.COUCH_HOSTNAME}:${env.COUCH_PORT}`
),
// App Server
httpPort: asOptional(asNumber, parseInt(env.HTTP_PORT)),
// Info Server
infoServerAddress: asOptional(asString, env.INFO_SERVER_ADDRESS),
infoServerApiKey: asOptional(asString, env.INFO_SERVER_API_KEY),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section will become a merge conflict when you rebase your PR - I already cleaned this section up.

pm2.json Outdated
Comment on lines 1 to 10
{
"apps": [
{
"name": "server",
"script": "lib/indexApi.js",
"error_file": "logs/server/error.log",
"out_file": "logs/server/out.log"
}
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server should have a real name, and the output should continue going to /var/log:

{
  "apps": [
    {
      "name": "logsServer",
      "script": "./lib/indexApi.js",
      "out_file": "/var/log/logsServer.log"
    }
  ]
}

Copy link
Contributor

@swansontec swansontec Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, on the production box it's /var/log/logsApi.log, but I think logsServer is a better name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should add this to the readme:

Manage server using pm2

First, install pm2 to run at startup:

yarn global add pm2
pm2 startup # Then do what it says

Next, tell pm2 how to run the server script:

# install:
pm2 start pm2.json
pm2 save

# check status:
pm2 monit
tail -f /var/log/logsServer.log

# manage:
pm2 restart logsServer
pm2 reload logsServer
pm2 stop logsServer

.gitignore Outdated

# Logs:
logs/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary if the output goes to /var/log

@paullinator paullinator force-pushed the master branch 2 times, most recently from fa42ba8 to 4e951b7 Compare February 24, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants