Failed to start a Parse-Server-Example app on Heroku
I have cloned the Parse-Server-Example repo to my own account on GitHub as "https://github.com/{MY_ACCOUNT}/ParseServerExample".
Then I tried to deploy the Parse-Server-Example repo as a Heroku application. All Config Variables on Heroku have been set up, e.g. APP_ID, MASTER_KEY, MONGOLAB_URI, PARSE_MOUNT and REST_API_KEY. My previous Parse hosted MongoDB database has been migrated to MongoLab successfully.
When I tried to deploy via GitHub not Heroku Git, it was correctly connected to my repo and deployment was apparently running well. It showed "Deployed to Heroku". But when I clicked the "View" button, it game me a "Applicaiton Error" page. I then clicked "View logs", Heroku logs showed the following error message:
State changed from crashed to starting
2016-02-25T05:13:55.607626+00:00 app[web.1]: > node index.js
2016-02-25T05:13:59.030078+00:00 app[web.1]:
2016-02-25T05:13:59.086298+00:00 app[web.1]: npm ERR! Linux 3.13.0-77-generic
2016-02-25T05:13:59.087035+00:00 app[web.1]: npm ERR! node v5.6.0
2016-02-25T05:13:59.088165+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-02-25T05:13:59.088380+00:00 app[web.1]: npm ERR! [email protected] start: `node index.js`
2016-02-25T05:13:59.094116+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node index.js'.
2016-02-25T05:13:59.094277+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2016-02-25T05:13:59.094475+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the ParseServerExample package,
2016-02-25T05:13:59.094680+00:00 app[web.1]: npm ERR! not with npm itself.
2016-02-25T05:13:59.095077+00:00 app[web.1]: npm ERR! node index.js
2016-02-25T05:13:59.095463+00:00 app[web.1]: npm ERR! npm bugs ParseServerExample
2016-02-25T05:13:59.095846+00:00 app[web.1]: npm ERR! npm owner ls ParseServerExample
2016-02-25T05:13:59.030140+00:00 app[web.1]: /app/node_modules/parse-server/lib/requiredParameter.js:8
2016-02-25T05:13:59.030141+00:00 app[web.1]: throw errorMessage;
2016-02-25T05:13:59.030142+00:00 app[web.1]: ^
2016-02-25T05:13:59.030146+00:00 app[web.1]: **You must provide a serverURL!**
2016-02-25T05:13:59.059589+00:00 app[web.1]:
2016-02-25T05:13:59.086754+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-02-25T05:13:59.087914+00:00 app[web.1]: npm ERR! npm v3.6.0
2016-02-25T05:13:59.088588+00:00 app[web.1]: npm ERR! Exit status 1
2016-02-25T05:13:59.088801+00:00 app[web.1]: npm ERR!
2016-02-25T05:13:59.094872+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-02-25T05:13:59.095263+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-02-25T05:13:59.095668+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-02-25T05:14:00.007554+00:00 heroku[web.1]: State changed from starting to crashed
I guess the problem was about "serverURL". Do I need to set up a "serverURL" anywhere in index.js?
Yes you need to include choose a server URL, usually you should choose localhost/parse or the location where your server is hosted. Did you deploy via the heroku button? If so, we should probably fix that button to include a server URL.
Thanks for the reply. My Parse-server-example app was NOT deployed via the Heroku button but instead deployed via GitHub repo that was cloned to my own account on GitHub from the original Parse-server-example. The index.js does not contain any need to include serverUrl.
As both the readme and error states, you need to include serverUrl:
// Specify the connection string for your mongodb database // and the location to your Parse cloud code var api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/dev', cloud: '/home/myApp/cloud/main.js', // Provide an absolute path appId: 'myAppId', masterKey: 'myMasterKey', // Keep this key secret! fileKey: 'optionalFileKey', serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed });
I used the Herkou button and ran into this same thing....
Yes, the Heroku button uses this project: https://github.com/ParsePlatform/parse-server-example
And https://github.com/ParsePlatform/parse-server-example/blob/master/index.js needs to be updated with the serverURL parameter. See https://github.com/ParsePlatform/parse-server-example/issues/74
We got some PRs from Heroku and Azure that fix the buttons, they should work now.
Tried to do a deploy with the new button and still getting the Application Error - https://quikto.herokuapp.com/
I used for Server Location: https://quikto.herokuapp.com/ And Parse Server Location: https://quikto.herokuapp.com/parse
Please advise if that was correct.
Try setting your server url to http://localhost/parse, that should give you better performance anyway.
Seem to still have issues, but looking.... One thing I noticed was a spelling error: PARSER_SERVER_URL
Should it be PARSE_SERVER_URL
I think it should just be SERVER_URL. Maybe just remove this app and create a new one, as it seems like you created it in the brief window when there was an erroneous heroku button.
NM, I got it up and running with the recent build now
Thanks for all the hard work guys, making this open is awesome. Really looking forward to the full data browser when its released! I really loved the Parse UI online.
I am getting the message on heroku "Make sure to star the parse-server repo on GitHub!"
I have migrated using heroku button.
How to get out of this?
Regards
_Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details._
://
Hi Everybody, To well configure your app on Heroku, when all the tutorial you have read seems to not help you, the best way to fix your problem is to read the program you want to use when it's possible. In our case, we r lucky, it's open source. So we can read it. Here is a part of the index.js file of the parse-server-example
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
fileKey: process.env.FILE_KEY || 'noFileKey', //to display files load in the old parse system
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
With this part of the code, you can find all the config variables that you need to set up for your program. First of all var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI; Here you can see that you can use DATABASE_URI or MONGODB_URI, to link your program to your database solution.
As I read the message of @grassland-curing-cfa he has written that he has configured all the config variables and then talk about MONGOLAB_URI . It was the name of this config variable in an old version of the parse-server-example. I didn't find any documentation about this evolution.
In other way, as I know you will surely face to this probleme after that you fixe this one, you can also see that I have add this line in the creation of the var api as a new instance of the ParseServer object : fileKey: process.env.FILE_KEY || 'noFileKey', //to display files load in the old parse system
I don't know if you already know but the actual version of the migration of the MongoDB database on Parse.com to your new solution don't manage the transfer of your files (photos, videos and other). There are still stored on the Parse.com server. When you will connect your application to your heroku program and want to display an image or a video, you will have an error. You will see that all your URL will be like this : https://files.parsetfss.com/invalid-file-key/tfss-9c0f039d-2705-43e1-9ff4-1f95bd31a129-0722_Cloud10.jpg
To fix it, you have to add the line concerning the file key as I have done. I'm not a javascript developper, and I don't know if the order of the parameters declare is important. But, when you read the code of the ParseServer object in the Parse-server application (used by the Parse-Server-Example app) , you can see all the parameters that you can use to instantiate a ParseServer object. The fileKey parameter is optionnal but it comes after the serverURL parameter and before the liveQuery So this is why I write it there.In more, as I have test it in an another order, it didn't work.
class ParseServer {
constructor({
appId = requiredParameter('You must provide an appId!'),
masterKey = requiredParameter('You must provide a masterKey!'),
appName,
filesAdapter,
push,
loggerAdapter,
logsFolder,
databaseURI,
databaseOptions,
databaseAdapter,
cloud,
collectionPrefix = '',
clientKey,
javascriptKey,
dotNetKey,
restAPIKey,
webhookKey,
fileKey = 'invalid-file-key',
facebookAppIds = [],
enableAnonymousUsers = true,
allowClientClassCreation = true,
oauth = {},
serverURL = requiredParameter('You must provide a serverURL!'),
maxUploadSize = '20mb',
verifyUserEmails = false,
cacheAdapter,
emailAdapter,
publicServerURL,
customPages = {
invalidLink: undefined,
verifyEmailSuccess: undefined,
choosePassword: undefined,
passwordResetSuccess: undefined
},
liveQuery = {},
sessionLength = 31536000, // 1 Year in seconds
expireInactiveSessions = true,
verbose = false,
revokeSessionOnPasswordReset = true,
__indexBuildCompletionCallbackForTests = () => {},
})
After that you have update your index.js file, make a manual deploy on Heroku. If you want to be sure that the last version of your githup repo has well been upload just write your own the sentence to replace the default one at this line ('I dream ...')
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!');
});
At the end, keep in mind that after that you have less than half a year to definitely migrate your files "physically" from the parse.com storage solution to the one you will choose.
Good luck to everyone!