I have trouble getting my new app to run. It is a remix app with express. Here is my package.json
{
"private": true,
"name": "moaclayco",
"description": "",
"license": "",
"scripts": {
"css": "tailwindcss --output ./app/styles/tailwind.css --config ./tailwind.config.js --watch",
"dev2": "remix run",
"postinstall": "remix setup node",
"start": "remix-serve build",
"dev": "pm2-dev ./other/pm2.config.js",
"build:css": "postcss styles/**/*.css --base styles --dir app/styles",
"build:css:prod": "npm run build:css -- --env production",
"clean": "rimraf ./node_modules/.cache ./server/dist ./build ./public/build \"./app/styles/**/*.css\"",
"prebuild": "npm run clean && echo All clean ✨",
"build:remix": "cross-env NODE_ENV=production remix build",
"build": "npm run build:css:prod && npm run build:remix"
},
"dependencies": {
"@remix-run/express": "^1.2.3",
"@remix-run/react": "^1.2.3",
"@remix-run/serve": "^1.2.3",
"@stripe/react-stripe-js": "^1.6.0",
"@stripe/stripe-js": "^1.21.1",
"compression": "^1.7.4",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"framer-motion": "^5.3.0",
"mongoose": "^6.0.12",
"nodemailer": "^6.7.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.0.2",
"react-router-hash-link": "^2.4.3",
"react-swipeable": "^6.2.0",
"react-use-cart": "^1.13.0",
"remix": "^1.2.3",
"stripe": "^8.186.1",
"tailwindcss": "^2.2.19"
},
"devDependencies": {
"@remix-run/dev": "^1.2.3",
"@tailwindcss/aspect-ratio": "^0.3.0",
"@tailwindcss/forms": "^0.3.4",
"@tailwindcss/line-clamp": "^0.2.2",
"@tailwindcss/typography": "^0.4.1",
"@types/node": "^16.11.6",
"@types/nodemailer": "^6.4.4",
"@types/react": "^17.0.24",
"@types/react-dom": "^17.0.9",
"@types/react-router-hash-link": "^2.4.4",
"@types/stripe": "^8.0.417",
"autoprefixer": "^10.4.0",
"cross-env": "^7.0.3",
"pm2": "^5.1.2",
"postcss": "^8.3.11",
"postcss-cli": "^9.0.1",
"postcss-import": "^14.0.2",
"prettier": "^2.4.1",
"prettier-plugin-tailwind": "^2.2.12",
"rsync": "^0.6.1",
"typescript": "^4.1.2"
},
"engines": {
"node": ">=14"
},
"sideEffects": false
}
And the fly.toml
app = "moaclayco"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 3000
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "10s"
interval = "15s"
restart_limit = 0
timeout = "2s"
My index.js
require('@remix-run/node/globals').installGlobals()
const path = require('path')
const express = require('express')
const {createRequestHandler} = require('@remix-run/express')
const compression = require('compression')
const connector = require('./connector')
connector()
const MODE = process.env.NODE_ENV
const BUILD_DIR = path.join(process.cwd(), 'build')
let app = express()
app.use(compression())
app.use(express.static('public', {maxAge: '1w'}))
app.use(express.static('public/fonts', {immutable: true, maxAge: '1y'}))
app.use(express.static('public/images', {immutable: true, maxAge: '1y'}))
app.use(express.static('public/build', {immutable: true, maxAge: '1y'}))
app.all(
'*',
MODE === 'production'
? createRequestHandler({build: require(BUILD_DIR)})
: (req, res, next) => {
purgeRequireCache()
const build = require(BUILD_DIR)
return createRequestHandler({build, mode: MODE})(req, res, next)
},
)
const port = process.env.PORT ?? 3000
app.listen(port, () => {
require(BUILD_DIR)
console.log(`Express server listening on port ${port}`)
})
function purgeRequireCache() {
for (const key in require.cache) {
if (key.startsWith(BUILD_DIR)) {
delete require.cache[key]
}
}
}
All secrets are set but in the log I’m getting this.
2022-03-01T15:46:36Z runner[51adcb49] fra [info]Unpacking image
2022-03-01T15:46:40Z runner[51adcb49] fra [info]Preparing kernel init
2022-03-01T15:46:41Z runner[51adcb49] fra [info]Configuring firecracker
2022-03-01T15:46:41Z runner[51adcb49] fra [info]Starting virtual machine
2022-03-01T15:46:41Z app[51adcb49] fra [info]Starting init (commit: 0c50bff)...
2022-03-01T15:46:41Z app[51adcb49] fra [info]Preparing to run: `docker-entrypoint.sh npm run start` as root
2022-03-01T15:46:41Z app[51adcb49] fra [info]2022/03/01 15:46:41 listening on [fdaa:0:3d01:a7b:23c4:51ad:cb49:2]:22 (DNS: [fdaa::3]:53)
2022-03-01T15:46:42Z app[51adcb49] fra [info]> start
2022-03-01T15:46:42Z app[51adcb49] fra [info]> remix-serve build
2022-03-01T15:46:42Z app[51adcb49] fra [info](node:532) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
2022-03-01T15:46:42Z app[51adcb49] fra [info](Use `node --trace-warnings ...` to show where the warning was created)
2022-03-01T15:46:42Z app[51adcb49] fra [info]Remix App Server started at http://172.19.2.58:3000
2022-03-01T15:47:10Z runner[55aeb663] cdg [info]Shutting down virtual machine
2022-03-01T15:47:10Z app[55aeb663] cdg [info]Sending signal SIGINT to main child process w/ PID 515
2022-03-01T15:52:58Z app[51adcb49] fra [info]GET / - - - - ms