Lumber Deploy -c Doesn't seem to work

Hi Again!

So I’ve managed to configure it in the backend and link my DB up and get some basic fields setup. I now want to deploy it to production… I followed the tutorial on youtube by going into the development enviroment and then running lumber deploy -c but then nothing happens… I’m currently hosting the admin backend on an EC2 instance and the actual endpoint domain is on a VPS. I have the VPS domain, SSL etc setup but just trying to deploy and can’t…

Help!

Thanks!

1 Like

Hi ! Can you share the tutorial you have been following ?

Yeah this is a pretty old tutorial, you should follow the official documentation (which is kept up to date :slight_smile: )

Okay cool, so used git to copy over files to other server. Now tried to run npm start after installing and getting this error…

/var/www/etc.unioneducationgroup.com/html/uegforestadmin/app.js:32
  ...corsConfig,
  ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/www/etc.unioneducationgroup.com/html/uegforestadmin/server.js:5:13)

npm ERR! Linux 3.10.0-1160.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v6.17.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! ueg-admin@0.0.1 start: `node ./server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ueg-admin@0.0.1 start script 'node ./server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ueg-admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ueg-admin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ueg-admin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/etc.unioneducationgroup.com/html/uegforestadmin/npm-debug.log

Can you share the server.js file please ?

require('dotenv').config();
const debug = require('debug')('{name}:server');
const http = require('http');
const chalk = require('chalk');
const app = require('./app');

function normalizePort(val) {
  const port = parseInt(val, 10);

  if (Number.isNaN(port)) { return val; }
  if (port >= 0) { return port; }

  return false;
}

const port = normalizePort(process.env.PORT || process.env.APPLICATION_PORT || '3310');
app.set('port', port);

const server = http.createServer(app);
server.listen(port);

function onError(error) {
  if (error.syscall !== 'listen') {
    throw error;
  }

  const bind = typeof port === 'string'
    ? `Pipe ${port}`
    : `Port ${port}`;

  switch (error.code) {
    case 'EACCES':
      console.error(`${bind} requires elevated privileges`);
      process.exit(1);
      break;
    case 'EADDRINUSE':
      console.error(`${bind} is already in use`);
      process.exit(1);
      break;
    default:
      throw error;
  }
}

function onListening() {
  const addr = server.address();
  const bind = typeof addr === 'string'
    ? `pipe ${addr}`
    : `port ${addr.port}`;
  debug(`Listening on ${bind}`);

  console.log(chalk.cyan(`Your application is listening on ${bind}.`));
}

server.on('error', onError);
server.on('listening', onListening);

Thanks, and your app.js ?

const app = express();

let allowedOrigins = [/\.forestadmin\.com$/];

if (process.env.CORS_ORIGINS) {
  allowedOrigins = allowedOrigins.concat(process.env.CORS_ORIGINS.split(','));
}

const corsConfig = {
  origin: allowedOrigins,
  allowedHeaders: ['Authorization', 'X-Requested-With', 'Content-Type'],
  maxAge: 86400, // NOTICE: 1 day
  credentials: true,
};

app.use(morgan('tiny'));
app.use('/forest/authentication', cors({
  ...corsConfig,
  // The null origin is sent by browsers for redirected AJAX calls
  // we need to support this in authentication routes because OIDC
  // redirects to the callback route
  origin: corsConfig.origin.concat('null')
}));
app.use(cors(corsConfig));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use(jwt({
  secret: process.env.FOREST_AUTH_SECRET,
  credentialsRequired: false,
}));

app.use('/forest', (request, response, next) => {
  if (PUBLIC_ROUTES.includes(request.url)) {
    return next();
  }
  return ensureAuthenticated(request, response, next);
});

requireAll({
  dirname: path.join(__dirname, 'routes'),
  recursive: true,
  resolve: (Module) => app.use('/forest', Module),
});

requireAll({
  dirname: path.join(__dirname, 'middlewares'),
  recursive: true,
  resolve: (Module) => Module(app),
});

app.use(errorHandler());

module.exports = app;

You don’t have those require ?

const express = require('express');
const requireAll = require('require-all');
const path = require('path');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const cors = require('cors');
const jwt = require('express-jwt');
const morgan = require('morgan');
const { errorHandler, logger } = require('forest-express');

You are using node 6, please upgrade to node 12.13.0 (you version does not support the es6)

Hi @anon94532230

I’m not having any luck… I managed to run the nodeJS app on the server-side but I really don’t know what to do from here… I have tried to go through the the add production setup and I change my enviroment variables to the one on the screen reboot the server and still nothing. Right now in the console, I’m getting a CORS error, which I’ve checked the CORS config and is all correct. - So my steps from start to finish…

  1. Cloned files to a private github repository from Admin
  2. Went to my other server and navigated to the virtual site setup in /var/www/{subdomain}/
  3. Copied GIT repository to there.
  4. Ran npm install
  5. Change my Enviroment config
  6. Restarted my server and httpd and firewalld
  7. Ran the App.

When I run the app it returns this…

> ueg-admin@0.0.1 start /var/www/etc.unioneducationgroup.com/html
> node ./server.js

Your application is listening on port 3310.
Your admin panel is available here: https://app.forestadmin.com/projects

I’m not sure what’s wrong here…

Hi @Louie_Heaton,

Once started, you should be able to see this screen using your production URL. Is that the case ?

image

Also, could you provide me your project name so I can check in our internal tools if I can see any issues?