Connecting Parse-Server to Heroku - ios

Hey I'm having trouble connecting my Parse-Server to my Heroku app. I've been following this: https://github.com/parse-community/parse-server and I've done the first step for installing it locally by using npm install -g parse-server mongodb-runner which worked fine. However, the following steps to set up my AppID, MasterKey and MongoDB databaseURI don't work. I have all of these things already as I've used parse-server-example, however running this command parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test with the correct information hasn't worked for me, and I don't know what file to put my keys in. If someone could help me that would be very much appreciated as I just went in circles on this for 9+ hours today.
Thank you!
When I try node index.js
When I try npm install
Cloud Code Error

You should put your keys in index.js file. To run parse server locally, you need to use node index.js in your command line.
If you want to connect to heroku, you need to make a Procfile(simply touch Procfile), then add web: npm start into the file.
After you push to Heroku, go to settings, reveal config vars, then put all your keys there.
Both DATABASE_URI and MONDODB_URI should be your mongodb url(not local). SERVER_URL should be the heroku app url.

Related

How to edit permissions on Heroku application?

My problem in simple terms is that I have an executable that can't be run on Heroku, because it doesn't have the right permissions.
In more details, I have a RoR application on Heroku and I want to use server pdftk. But after installing it I need to chmod the file to be able to use it. And if I run a console on Heroku dashboard, put the chmod command in and try running pdftk it works, but it works just for that temporary dyno and it doesn't work on production server.
I tried creating .profile and putting the command in and that didn't work.
I tried creating Procfile and put release: chmod u+x /app/vendor/pdftk/bin/pdftk and it didn't work.
I tried all different versions of release, web, worker...
I tried creating a .sh file and putting the command in there and then running the file and it doesn't work either.
command for setting permission: chmod u+x /app/vendor/pdftk/bin/pdftk
If you need more info, please tell me.
Any help would be appreciated.
Okay, I figured out what the problem was.
I have a pipeline from gitlab and the permissions just needed to be set through git, so that they were correct when they came to the production enviroment.
I needed to run this code:git update-index --add --chmod=+x pdftk

Connecting to different ARN/Role/Amazon Account when trying to deploy

I have previously had Serverless installed on a server, and then when I tried to edit the function and package it back up to edit the zip file I broke it, so I have to start all over. So to begin this issue: I had Serverless running and was using it with this package - https://github.com/adieuadieu/serverless-chrome/tree/master/examples/serverless-framework/aws
When I sudo npm run deploy, I get the ServerlessError:
ServerlessError: User: arn:aws:sts::XXX:assumed-role/EC2CodeDeploy/i-268b1acf is not authorized to perform: cloudformation:DescribeStackResources on resource: arn:aws:cloudformation:us-east-1:YYY:stack/aws-dev/*
I'm not sure why it is trying to connect to a Role and not an IAM. So I check the Role, and it is in an entirely different AWS account than the account I've configured. Let's call this Account B.
When it comes to configuration, I've installed AWS CLI and entered in the key, id, and region in my Account A in AWS. Not touching Account B whatsoever. When I run aws s3 ls I see the correct s3 buckets of the account with the key/id/regioin, so I know CLI is working with the correct account. Sounds good. I check the ~/.aws/creditionals file and just has one profile [default] which seems normal. No other profiles are in here. I copied this over to the ~/.aws/config file so now both files are same. Works great.
I then go into my SSH where I've installed serverless, and run npm run deploy and it gives me the same message above. I think maybe somehow it is not using the correct account for whatever reason. So I manually set the access key and secret with the following commands:
serverless config credentials --provider aws --key XXX --secret YYY
It tells me there already is a profile in the aws creds file, so I then add --o to the end to overwrite. I run sudo npm run deploy and still same error.
I then run this command to manually set a profile in the creds for serverless, with the profile name matching the IAM user name:
serverless config credentials --provider aws --key XXX --secret YYY --profile serverless-agent
Where "serverless-agent" is the name of my IAM user I've been trying to use to deploy. I run this, it tells me there already is an existing profile in the aws creds file so I run it with --o and it tells me the aws file is now updated. In bash I go to Vim the file and I only see the single "[default]" settings, as if nothing has changed. I run sudo npm run deploy and it gives me the same Error.
I then go and manually set the access and secret:
export AWS_ACCESS_KEY_ID=XXX
export AWS_SECRET_ACCESS_KEY=YYY
I run sudo npm run deploy and it gives me the same Error.
I even removed AWS CLI, and the directory that holds the creditionals and config files - and when I manually set my account creds via serverless config it tells me there already is a profile set up in my aws file, prompting me to use the overwrite command - how is this possible when the file is literally not on my computer?
So I then think that serverless itself has a cache or something, calling the wrong file or whatever for creds, so I uninstall serverless via sudo npm uninstall -g serverless so that I can start from zero again. I then do all of the above steps and more all over again, and nothing has changed. Same error message.
I do have Apex.run set up, but that should be using my AWS CLI config file so I'm not sure if that is causing any problems. But then again I've no clue of anything deep on this subject, and I can't find any ability to remove Apex itself in their docs.
In the package I am trying to deploy, I do not have a profile:XXX set in the serverless.yml file, because I've read if you do not then it just defaults to the [default] profile you have set in the aws creds file on your computer. Just to check, I go into the serverless.yml file and set the profile: default, and the error I now get when I run npm run deploy is
Profile default does not exist
How is that possible when I have the "default" profile set in my creds file? So I remember that previously I ran the serverless config creditionals command and added the profile name of serverless-agent to it (yet didn't save in the aws creds file as I mentioned above), so I add that profile name to the serverless.yml file just to see if this works, and same error of "Profile default does not exist".
So back to the error message. The Role is an account not even related to the IAM user I'm using in my aws creds. Without knowing a lot about this, it's as if the config in serverless via ssh isn't correct or something. Is it using old creds I had set up in Apex.run? Why is the aws creds file not updated with the profile when I manually set it in serverless config command? I am using the same user account (but with new key and secret) that I used a few weeks ago when I correctly deployed and my Lambda and API was set up for me on AWS. Boy do I miss those time and wish I didn't mess up my existing Lambda functions, without setting version number prior, forcing me to start all over.
I am so confused. Any help would be greatly appreciated.
If you are using IAM role then you have to use that IAM role through assume role using powershell.
I was also facing same issue earlier, when we moved from from user to role.

Pronto-Rubocop on Gitlab is not working, wrong URL being called

I'm using:
Gitlab 7.11.2
Rails 3.2
Pronto 0.4.2
pronto-rubocop 0.4.4
And I'm having trouble setting up the script to run Rubocop on git commits. I want to use Pronto so only the changes are checked. I am not using GitLab to host so I am not sure how to proceed when I reach this point of the Pronto setup, https://github.com/mmozuras/pronto:
Set the GITLAB_API_ENDPOINT environment variable to your API endpoint URL. If you are using Gitlab.com's hosted service your endpoint will be https://gitlab.com/api/v3. Set the GITLAB_API_PRIVATE_TOKEN environment variable to your Gitlab private token which you can find in your account settings.
Then just run it:
GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
Where do I run the last command?:
GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
I created a .gitlab-ci.yml file and it has:
before_script:
- ruby -v
- gem install bundler --no-ri --no-rdoc
- bundle --without postgres
rubocop:
script: bundle exec pronto run --index
But I can't tell if this is running.
I also did not set up GitlabFormatter as it is mentioned on the Pronto page, when I tried looking up information about it was vague and unhelpful to me.
Can someone point me in the right direction?
Thanks!
**UPDATE
So I gave up on using .gitlab-ci.yml file route for now because the job on gitlab-ci worked. I figured out the endpoint and installed all the necessary requirements on the server and everything bundles correctly.
At the very end of the process, I run:
GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
But the URL it generates is incorrect and I cannot add comments to the commit:
https://gitlab.com/api/v3/projects/10022%2Fname%2Fapp-name/repository/commits/ad87234..asdf87923/comments
I'm getting an
(Gitlab::Error::NotFound)
and I looks like it is coming from this part of code:
../10022%2Fname%2Fapp-name/..
because I can see the JSON when I change it to
../name/app-name/..
Any idea on how to call the correct URL?
Finally got this working. I am hosting gitlab on my own server, the API endpoint will look up the correct project as long as you have "api/v3" at the end. It's when you specify projects that things can go wrong, you'll know this if you see errors similar to these:
"Project not found" --> don't specify the project
"Unauthorized" --> are you using the correct user token?
Finally, even after pronto is run and it tells you how many errors were found or how many comments left, it might not always show up on the commit BUT if you submit a merge request the rubocop comments will show up.
To have the gitlab build fail if there are style guide violations run pronto with the option:
--exit-code

React cannot find entry file in any of the roots

I am using React Native as a Pod in my iOS project.
When I try to load a view that I created with React Native I get the Error screen referring me to the Terminal window where npm is running.
In the Terminal the error I am seeing is:
Error: Cannot find entry file in any of the roots:
I tried a few things, moving the file to a different location, but no luck.
I did run "npm start" and I am looking for the file in "http://localhost:8081/".
The current location of the file is in the same location as where I ran "npm start" from.
I am completely stuck here.
Did I configure something wrong. How can I troubleshoot from here?
Check for the node server running in one of the bash terminal, this was probably kicked by previous ReactNative XCode project you launched earlier. Stop that process and run XCode project again, this should fix the problem.
Sorry for answering my own question (a bit lame), but I hope it helps somebody else.
Apperantly we need run the npm command by giving an alternative path.
npm run start -- --root <directory_with_your_react_component_js_sources>
On http://facebook.github.io/react-native/docs/embedded-app.html#content is a guide on how to integrate React Native in an existing app.
That happens when React wants to use a port that is already being used by other application. Since React listens to port 8081, you can get the process running at that port typing the following in Shell:
lsof -n -i4TCP:8081
You'll get an answer like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 28571 username 32u IPv6 0x742e2ab233abdb9f 0t0 TCP *:sunproxyadmin (LISTEN)
Just killed that by typing in shell
kill -9 <PID>. Use the same PID that has been provided in the last answer.
Then run npm start.
There's this issue:
https://github.com/facebook/react-native/issues/541
Which seems the same thing. The user there seemed to indicate that they had run the project from that directory before, which leads me to wonder if this is due to a hanging or left-over packager from a previous run? Try closing the terminal window and re-running the Xcode project.
In general this sounds like an issue with the packager not generating the files as expected. Are there any other messages in the terminal window?
I wanted to update this after getting a bit frustrated my setup still wasn't working after killing all node processes and running the command above.
There seems to be a ReactNative open issue at present: https://github.com/facebook/react-native/issues/14246
The solution for this is to kill the externally launched package manager and just run "npm start" in the project folder.
Check if you have index.ios or index in your AppDelegate.m:
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index.ios" fallbackResource:nil];
I had index and I was previously using index.ios and index.android so that's why it was failing.
In my experience, it is because of Watchman and Jest.
The solution I've found is
add
name = name.replace('/', '\\');
to 'node_modules\jest-haste-map\build\crawlers\watchman.js'
You can check further info here
Watchman not working with React Native

Reloading nginx config from within a rails app

I have a multi-app system running on a centOS box, that consists of our main app and a deployer app. when a client wants a new instance of our app, they use our deployer, fill in some info and the new install is created on our server. the issue i am having is that i can't get nginx to reload it's config file automatically. so after the deploy when visiting the new app we receive a 404 until i reload manually.
I've tried a few different ways including chmod /opt/nginx/sbin/nginx to 777, chmod the install script and deployer app to 777,
the script goes like this:
#create install directory -- works correctly
#copy files over -- works correctly
#run install script
##-- and then at this point i've tried multiple lines, including:
system("nginx -s reload") ## this works manually
system("/etc/init.d/nginx reload") ## this works manually
i've followed directions here: Restart nginx without sudo? to create a script to run without a sudo password and then tried this:
system("sudo /var/www/vhosts/deployer/lib/nginx_reload")
nothing seems to work, i'm assuming this is a permissions error, but maybe i'm wrong, if anyone could point me in any direction, that would be very helpful since i've been trying to figure this out for a few days too long and i'm fresh out of new ideas
sudo /etc/init.d/nginx reload

Resources