-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
Conversation
6817af3
to
5660cf8
Compare
Remove unused config fields and parameterize config with optional ENV.
5660cf8
to
b2c00d2
Compare
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
)
// 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), |
There was a problem hiding this comment.
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
{ | ||
"apps": [ | ||
{ | ||
"name": "server", | ||
"script": "lib/indexApi.js", | ||
"error_file": "logs/server/error.log", | ||
"out_file": "logs/server/out.log" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
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"
}
]
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/ |
There was a problem hiding this comment.
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
fa42ba8
to
4e951b7
Compare
This is a draft until successfully testing on a new test droplet