Too long response from my app deployed on Heroku - heroku

I'm very new in using Heroku.
I deployed my telegram-bot using free plan on Heroku to test how it works. But it works great only first 2-3 minutes, after that period of all responses from the app take up to 6 hours per each!
In documentation: app will sleep after 30 minutes of no-requests, but I can't find any info about requests take 5-6 hours for response by using free plan.
I tried autodeployment and manual deployment, same situation.
Source code is on GitHub.
Deployment on local machine works great 24/7.
Thank you in advance!
UPD:
It tryes to bind to some $PORT after 90 secs of starting app. Have no idea what does it mean.
After crushing heroku restarts app, sometimes restarts are succeed, sometimes are not.
Logs:
Mar 09 20:43:37 javamethodabot app/api Build succeeded
Mar 09 20:44:49 javamethodabot heroku/web.1 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
Mar 09 20:44:49 javamethodabot heroku/web.1 Stopping process with SIGKILL
Mar 09 20:44:49 javamethodabot heroku/web.1 Process exited with status 137
Mar 09 20:44:50 javamethodabot heroku/web.1 State changed from starting to crashed
Mar 09 20:44:50 javamethodabot heroku/web.1 State changed from crashed to starting

Related

Avoid waiting for user when checking the Apache Tomcat status

As part of a bash script I check the recently installed Apache Tomcat status with
sudo systemctl status tomcat
The output is as follows
● tomcat.service
Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-01-30 16:25:48 UTC; 3min 9s ago
Process: 175439 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 175447 (java)
Tasks: 30 (limit: 4546)
Memory: 253.0M
CPU: 9.485s
CGroup: /system.slice/tomcat.service
└─175447 /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.uti>
Jan 30 16:25:48 vps-06354c04 systemd[1]: Starting tomcat.service...
Jan 30 16:25:48 vps-06354c04 startup.sh[175439]: Tomcat started.
Jan 30 16:25:48 vps-06354c04 systemd[1]: Started tomcat.service.
Jan 30 16:25:48 vps-06354c04 systemd[1]: /etc/systemd/system/tomcat.service:1: Assignment outside of section. Ignoring.
Jan 30 16:25:48 vps-06354c04 systemd[1]: /etc/systemd/system/tomcat.service:2: Assignment outside of section. Ignoring.
This is the info I expect to see, but after printing it, systemctl keeps waiting for the user to type a key, breaking the automation I expect to deliver.
How can I avoid this behaviour?
I'm pretty sure the --no-pager option would keep that from happening. I just confirmed that on my own system on a different service. Otherwise, it goes interactive.
I don't recall ever seeing systemctl status asking for input, so perhaps it's the sudo used in this command doing that, in which case you could ask your system administrator to enable passwordless sudo on the account that runs this command.
A general solution for automating user input in shell scripts is to use expect, but for a simple case where you only need to send a single value one time, you can often get by with using echo and piping the value to the command (e.g., echo 'foo' | sudo systemctl status tomcat), although you should never do this to pass sensitive information such as passwords because that will potentially be accessible to other users on that system.

Idle dyno still using free hours

As in topic, looks like my free dyno (I have only 1 dyno on my heroku account) uses free dyno hours when idle. Checked it and below you can see:
[user#host ~]$ heroku ps -a myapp
Free dyno hours quota remaining this month: 421h 16m (76%)
Free dyno usage for this app: 128h 43m (23%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping
=== web (Free): npm start (1)
web.1: up 2022/04/23 23:03:34 +0200 (~ 1m ago)
[user#host ~]$ heroku ps -a myapp
Free dyno hours quota remaining this month: 394h 53m (71%)
Free dyno usage for this app: 155h 5m (28%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping
=== web (Free): npm start (1)
web.1: idle 2022/04/23 23:36:32 +0200 (~ 15h ago)
[user#host ~]$ date
Sun Apr 24 15:32:04 CEST 2022
Which basically says that at 2022/04/23 23:03:34 +0200 I had 421h 16m remaining
Now Sun Apr 24 15:32:04 CEST 2022 I have 394h 53m remaining even though app is idle since 2022/04/23 23:36:32 +0200 so it was running for 30 more minutes without receiving web traffic...
Any idea what happened with all these dyno hours then? Or do I misunderstand how this works?

Can't start Cloudera Manager, site not reachable

I have a small cluster with three nodes on my home server for learning purpose.
It was working fine after it was initially set up.
I haven't used it for a month and today when I try to use it, I found Cloudera Manager GUI cannot be accessed, I checked the network between the 3 nodes are good, they can ping to each other.
On master node where CM is installed, I tried service cloudera-scm-server start, it shows me [OK] in green; when I check the status it shows the following info:
[root#pocnnr1n1 ~]# service cloudera-scm-server status -l
● cloudera-scm-server.service - LSB: Cloudera SCM Server
Loaded: loaded (/etc/rc.d/init.d/cloudera-scm-server; bad; vendor preset: disabled)
Active: active (exited) since Fri 2017-09-15 20:58:24 EDT; 18min ago
Docs: man:systemd-sysv-generator(8)
Process: 107428 ExecStop=/etc/rc.d/init.d/cloudera-scm-server stop (code=exited, status=1/FAILURE)
Process: 107467 ExecStart=/etc/rc.d/init.d/cloudera-scm-server start (code=exited, status=0/SUCCESS)
Sep 15 20:58:19 pocnnr1n1.raymond.com systemd[1]: Starting LSB: Cloudera SCM Server...
Sep 15 20:58:19 pocnnr1n1.raymond.com su[107494]: (to cloudera-scm) root on none
Sep 15 20:58:24 pocnnr1n1.raymond.com cloudera-scm-server[107467]: Starting cloudera-scm-server: [ OK ]
Sep 15 20:58:24 pocnnr1n1.raymond.com systemd[1]: Started LSB: Cloudera SCM Server.
So, is the Cloudera Manager service started or stopped?
When I try to access CM through GUI, it shows below in chrome:
This site can’t be reached
192.168.211.251 refused to connect. Search Google for 192 168 211 251 7180 ERR_CONNECTION_REFUSED
Can anyone help me to fix it? Thank you very much.
This indicates the Cloudera Manager startup runs into an error. What you should do is to check the log file of your Cloudera Manager, which should be located at /var/log/cloudera-scm-server directory. Since this is a POC cluster, I assume that when you set it up, you did not use the external database like MySQL. Instead, you probably used the embedded postgresql database. If that's the case, please make sure the embedded database process is running while you start up the Cloudera Manager Server. To check the status of embedded db, you can do
service cloudera-scm-server-db status
The error when I attempted to start mariadb and failed was because there are dead processes, could be related to previous failed attempt, I killed those failed processes, and restart the mariadb with success, after that, cloudera-scm-server starts successfully.
Thank you. I hope this help for later viewers.

start request repeated too quickly

I'm writing a bash-script but I often face this issue.
When I try to start or stop a service I often get:
start request repeated too quickly
How can I solve this problem?
It's for example when I try to restart docker or openshift-origin master.
sudo service origin-master restart
● origin-master.service - Origin Master Service
Loaded: loaded (/usr/lib/systemd/system/origin-master.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Wed 2016-02-17 08:22:11 UTC; 44s ago
Docs: https://github.com/openshift/origin
Process: 2296 ExecStart=/usr/bin/openshift start master --config=${CONFIG_FILE} $OPTIONS (code=exited, status=255)
Main PID: 2296 (code=exited, status=255)
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service: main process exited, code=exited, status=255/n/a
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Failed to start Origin Master Service.
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Unit origin-master.service entered failed state.
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service failed.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service holdoff time over, scheduling restart.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: start request repeated too quickly for origin-master.service
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Failed to start Origin Master Service.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Unit origin-master.service entered failed state.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service failed.
My script is just doing:
if [ $1 = "-u" ]
then
sudo service origin-master restart
fi
A manual restart is possible before I've executed the script. But after it it remains giving the error
This is a "feature" of systemctl. There is a parameter in the file that limits the restart frequency in seconds. Lower this while testing.
Edit the file
/etc/systemd/system/multi-user.target.wants/<your service here>
my example:
Restart=on-failure
StartLimitBurst=2
# Restart, but not more than once every 10 minutes
#StartLimitInterval=600
# Restart, but not more than once every 30s (for testing purposes)
StartLimitInterval=30
I suggest you familiarize yourself with systemd. That's what you're using under the hood when you run service. As #chepner says, the service is failing (as you can see from the second line of the log), and it's being restarted too quickly, triggering the error.
Try running journalctl -u origin-master.service to figure out why the error is happening.
Also, systemd cat origin-master.service will show you the Service Unit file that describes your service - there might be errors.
I had this problem on Ubuntu 20.4. And by adding execute permission to the ExecStart file the problem was solved.
sudo chmod +x /path/to/execfile
I have faced same issue and solved this problem like that:
if /var/log/mysql folder not exists:
sudo mkdir /var/log/mysql
and then give permission this folder:
sudo chown -R mysql:mysql /var/log/mysql
sudo systemctl stop mysql
sudo systemctl start mysql
in my case, there was a typing mistake in this file -> /etc/systemd/system/multi-user.target.wants/<your service here> so after tweaking necessary parameters, if you are still facing the same error, don't forget to check the file
In my case , is my /etc/docker/daemon.json file format error, when i make this true, run systemctl start docker the server start success.
Please try running the command :
td-agent --dry-run
This will give you the root cause.

Apache won't start -- says httpd module is loaded but isn't running

So I've been working with several Virtual Hosts on OS X 10.8.2. I'm using the Apache2 installation and MySQL to run name-based virtual hosts. They have all been working perfectly fine until last night. Suddenly, all of my virtual hosts redirect to a "Cannot connect to" page.
After fiddling around and eventually checking the error logs, I've concluded that Apache is NOT actually running. For example, ps aux | grep apache only returns the grep process. However, if I try sudo /usr/sbin/apachectl start I get "org.apache.httpd: Already loaded" in response.
I've checked my httpd.conf file and it looks perfectly fine. I can't see any changes to it. I also ran the syntax check command (which escapes my brain at the exact moment), and it returned OK. The only thing I found in my error logs, the last thing, was from yesterday, Feb 21, and it says: "[Thu Feb 21 21:46:02 2013] [notice] caught SIGTERM, shutting down"
Ever since then, my Apache errors logs contain nothing (because it's not running). I've restarted, tried restarting apache; I'm at a total loss as to why it thinks it's running even though it is not.
Any ideas?
In /var/logs/system.log when I try to start and restart Apache:
Feb 23 09:27:00 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8766]): Exited with code: 1
Feb 23 09:27:00 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:10 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8767]): Exited with code: 1
Feb 23 09:27:10 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:16 Baileys-MacBook-Pro.local sudo[8769]: bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/sbin/apachectl start
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8772]): Exited with code: 1
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:20 Baileys-MacBook-Pro.local sudo[8773]: bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/sbin/apachectl restart
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8777]): Exited with code: 1
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:26 Baileys-MacBook-Pro.local sudo[8778]: bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/bin/vi system.log
This problem persists after rebooting. Ever since the other day, it will not start but believes the httpd module is loaded.
I'm trying to find out via Google, but -- does anyone know how Apache checks if it's loaded? I know a lot of services lock files to run; is it possible Apache has a lock file somewhere that's still locked despite Apache not currently running?
NOTE: I've posted this on ServerFault, as well -- I'm posting this here as well because so far I'm not getting anything on ServerFault and I've been looking at Apache posts on StackOverflow, so I'm assuming Apache questions are fine for Stack.
I can reproduce the issue (kinda) by starting Apache when there's another process already listening on the same port that Apache wants to bind to (usually that's port 80). So check if there's perhaps another process listening on that port:
sudo lsof -i tcp:80 | grep LISTEN
EDIT: Perhaps easier: you can start Apache manually in debug mode to see what the reason is it won't start:
sudo /usr/sbin/httpd -k start -e Debug -E /dev/stdout
In my case (something already listening on port 80), it will produce:
(48)Address already in use: make_sock: could not bind to address 0.0.0.0:80
In my case I got:
(2)No such file or directory: httpd: could not open error log file
/private/var/log/apache2/error_log. Unable to open logs
Creating the directory apache2 made it running.
Do not know if this is relevant, but since I faced the same problem and I found an alternate solution, let me put in my 2c anyway.
Looked into this post when I got the same issue. Turns out that the httpd.conf file was the culprit. I had changed it to install something. Although I removed the installer files, I forgot to change the httpd.conf back. I hope you did not face the same problem.
Regarding question on port 80, I had seen skype hog the port as well as 443, (God knows for what) and I had better results after I turned it off. Make sure you do no have skype running on port 80 .
robertklep's pointer:
sudo /usr/sbin/httpd -k start -e Debug -E /dev/stdout
solved a related problem for me. Same symptoms, different cause, I think.
I set up a test virtual host with SSL & a self-signed certificate.
I had generated a private key with a passphrase.
So httpd was waiting for a passphrase (which I wasn't supplying).
When I started with the debug option, I got the prompt, supplied the passphrase & httpd started up.
So, will redo the private key without a passphrase...

Resources