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

Cloud Code: Function Code #1668

Closed
Droppix opened this issue Apr 28, 2016 · 7 comments
Closed

Cloud Code: Function Code #1668

Droppix opened this issue Apr 28, 2016 · 7 comments

Comments

@Droppix
Copy link

Droppix commented Apr 28, 2016

Hi,

I have a 3 parser-server running (dev/test/prod), and I try use the same file cloud code (main.js).
Can you confirm it's impossible use single Cloud Code file, for many servers ?

I obtain this error (via curl or PFCloud):
Error Domain=Parse Code=141 "Invalid function." UserInfo={code=141, temporary=0, error=Invalid function., NSLocalizedDescription=Invalid function.}

Works only, If I have duplicate cloud code file with other name.

Thanks

@bohemima
Copy link
Contributor

bohemima commented Apr 28, 2016

Works for me, not sure if I understood the question correctly however.

$ cat >> cloud.js
Parse.Cloud.define('test', function(req, res) { res.success('yay'); });
^D

$ parse-server --appId test1 --masterKey test1 --port 1337 --cloud cloud.js &>/dev/null &
$ parse-server --appId test1 --masterKey test1 --port 1338 --cloud cloud.js &>/dev/null &

$ curl -X POST -H "X-Parse-Application-Id: test1" -H "Content-Type: application/json" -d "{}" http://localhost:1337/parse/function/test
{"result":"yay"}

$ curl -X POST -H "X-Parse-Application-Id: test1" -H "Content-Type: application/json" -d "{}" http://localhost:1338/parse/function/test
{"result":"yay"}

Make sure you restart all your servers after changing any cloud code

@Droppix
Copy link
Author

Droppix commented Apr 28, 2016

Ok, because you have 2 servers on 2 ports (1337/1338).
Don't work if you have many servers on one port (1337)

@bohemima
Copy link
Contributor

Well, ofcourse you can not run two servers on the same port - there have been work to mount multiple ParseServers in one node app however. (Not sure if that will ever be a case)

I simply run a nginx that speaks to multiple parse-server instances (that run on different ports)

@Droppix
Copy link
Author

Droppix commented Apr 28, 2016

No, it's possible.
You can have many servers on one port, but on different path

example:
`
var apiProd = new ParseServer({
serverURL: 'https://xxxx:1337/xxxx',
databaseURI: 'mongodb://localhost:27017/xxxx',
cloud: '/....../cloud/main.js',
appId: '',
masterKey: '',
}
var apiR7 = new ParseServer({
serverURL: 'https://yyyy:1337/yyyy',
databaseURI: 'mongodb://localhost:27017/yyyyy',
cloud: '/....../cloud/main.js',
appId: '',
masterKey: ''
});

app.use('/xxxx', apiProd);
app.use('/yyyyy', apiR7);`

The only thing that does not work, that can not have the same Cloud Code.

@bohemima
Copy link
Contributor

This is exactly what is not supported, it was not clear in your initial question you mounted them like that.
See #15

It makes no sense running dev/test/prod in the very same server in any case.

@Droppix
Copy link
Author

Droppix commented Apr 28, 2016

You're quite right, it does not make sense, but it was for the purpose of study.

Ok, thanks

@hramos
Copy link
Contributor

hramos commented Apr 28, 2016

You may use Server Fault for questions about managing Parse Server.

For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.

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

No branches or pull requests

3 participants