how to get firebase cloud messanging running on local host - firebase

I try to get a simple firebase cloud message app, web, to run. The README of the sample app says:
1. On the command line run `firebase serve -p 8081` using the Firebase CLI tool to launch a local server.
That gives the error
Error: Cannot understand what targets to deploy/serve. If you are using PowerShell make sure you place quotes around any comma-separated lists (ex: --only "functions,firestore").
So I tried
firebase serve -p 8081 .
which returns
Having trouble? Try firebase [command] --help
How can I get a local web app that receives messages get running? Will similar troubles start again when hosting on firebase.
I am stuck. Firebase is an endless series of weird docu, weird results, all errors have been encountered by others and there are lon long threads on any of them.

Related

Is it possible to auto-retry firebase cloud-function deploys when doing a full deploy?

I have a large amount of cloud functions (150+) that need to be deployed. When i run the following: firebase deploy --only functions to do a full deploy i get the following message:
⚠ functions: too many functions are being deployed, cannot poll status.
In a few minutes, you can check status at https://console.firebase.google.com/project/.../functions/logs
You can use the --only flag to deploy only a portion of your functions in the future.
✔ Deploy complete!
indicating that the deploy is in progress. The issue i have is that usually several functions fail to deploy due to quota limits or other non-code ralated issues, and these have to be retried/redeployed. When polling firebase will give the code to use to retry these, however, when not polling then no further console output is given. When i access the interface i am able to see which functions failed to deploy:
enter image description here
Is there an option either in the google interface to retry these, or some command option that can be added to the deploy command to auto-retry failed functions? Currently i have to manually gather all the failed function-names by manually looking trough the list and run a deploy specifying only those.
There is no such option to automatically retry. Maybe you could write code to scan the logs to figure out what failed and retry yourself. Alternatively, you could instead invoke the CLI once for each individual function at a controlled rate, and check the results individually.
What you have here sounds like a feature request, which you could post to the firebase-tools GitHub repo. You could also reach out to Firebase support to make your needs known.

See continuous logging on command line

I am currently working on a Firebase function. As I am still in the development stage, I have a number of logs in my code to see what's going on.
async function getAddressByIdAsync(address) {
let addr = addressesRef.child(address);
console.log(addr);
return admin.database().ref('Addresses/' + address);
}
The only way I have found to be able to see these logs in real time is though the Firebase console, which is very slow and generally a bad UI experience IMO.
I'm looking for a command line solution that will let me see in real time the logs coming from the Firebase cloud function.
I have tried this command
firebase functions:log
Which appears to return the last twenty or so log entries into my Firebase Functions.
I know Google Cloud has a tail option on the end of that CLI but it doesn't work here.
firebase functions:log tail
Error: Too many arguments. Run firebase help functions:log for usage instructions
Is there a way to get a live running output of the logs from firebase cloud functions?
You can try the local emulator, that way you can first run your functions locally (and log in your terminal), before deploying.
https://firebase.google.com/docs/functions/local-emulator

Boxfuse is failing to create encrypted AMI

I have been using Boxfuse to deploy my app (PROD and TEST) without issues for well over a year, but now when trying to deploy to TEST (using the same command i've always used - boxfuse run app-name -env=test), I am getting this error.
"Running app/image failed!"
and that is it. It shows up just after "Waiting for AWS to create an encrypted AMI for app/image in us-west-2 (this may take up to 90 seconds)..." and the stack trace is
at com.boxfuse.client.core.Boxfuse.run(Boxfuse.java:653)
at com.boxfuse.client.commandline.Main.run(Main.java:325)
at com.boxfuse.client.commandline.Main.main(Main.java:133)
I am not sure where to begin in debugging this as the error message is not very descriptive and nothing has changed in my AWS account/settings or app configuration/setting etc. Any help or suggested places to start would be greatly appreciated. Thanks!

How to get the authenticated users in a heroku dyno?

Does anyone know how I can get the credentials of the logged user in a heroku dyno?
Context: We are trying to log access to Heroku production rails console. People access it via heroku run or heroku exec. Heroku does authenticate the users executed the command, however, I'm unable to retrieve this information once the rails console is started.
It looks like heroku cli is not available in the dyno, and whoami returns dyno.
Eg:
$ heroku run rails c -a opt-prod
<in rails console>
irb(main):001:0> ENV
irb(main):001:0> `whoami`
We contacted Heroku and there is no option to do this. Instead,
A running dyno doesn't contain
information on the user that started the process, so there's no way to
get the "current user" from inside a dyno on Heroku.
However, one idea for a workaround is to grab the current Heroku CLI
user and sends it along with the console command when starting.
Something like this will work:
CURRENT_HEROKU_USER="$CURRENT_HEROKU_USER" rails c --app my-app-name
> Running CURRENT_HEROKU_USER=chap#heroku.com rails c...
ENV['CURRENT_HEROKU_USER']
> "chap#heroku.com"
The downside of this approach is there's no way to validate that value from inside the dyno. However you could use
your application logs to retroactively verify the info. The API will
log the user who started the console process in your application logs:
CURRENT_HEROKU_USER=chap#heroku.com rails c by user chap#heroku.com
I'm sorry we don't have a better answer for you here.
Please let me know if I can be of more help.

Terminate and restart Google DataLab instance?

I am finding when working with larger datasets that the kernel may die, something I also experiance on my local machine. Sometimes it comes back and sometimes not. So even the Tree panel won't react to terminate a errant Kernel. EG "restart" does not work and the server itself seems to die. So the tree view won't respond or refresh. On my local machine I just kill the terminal instance and start over.
What is the "proper" way to restart everything?
FWIW the instance seems pegged at 150% cpu utilization atm
Related: is there any way to allow long running stuff to work?
I am trying to use a report generator (pandas-profiling) on a 2mm record dataset.. Works on my local..
found it here: https://cloud.google.com/datalab/getting-started
FWIW These commands can be used in the new command line shell on the Cloud console page.see https://cloud.google.com/shell/docs/ .. Without the sdk on your machine.. You need to modify the commands slightly since you will be logged into your project already,
Stopping/starting VM instances
You may want to stop a Cloud Datalab managed VM instance to avoid incurring ongoing charges. To stop a Cloud Datalab managed machine instance, go to a command prompt, and run:
$ gcloud auth login
$ gcloud config set project <YOUR PROJECT ID>
$ gcloud preview app versions stop main
After confirming that you want to continue, wait for the command to complete, and make sure that the output indicates that the version has stopped. If you used a non-default instance name when deploying, please use that name instead of "main" in the stop command, above (and in the start command, below).
For restarting a stopped instance, run:
$ gcloud auth login
$ gcloud config set project <YOUR PROJECT ID>
$ gcloud preview app versions start main

Resources