Can I monitor daemon/service with supervisord? - linux

I have a system-V init service/daemon running my application. I wanted to make sure that my application always runs even with conditions where process/service could crash, machine restart. I know of supervisord which is able to monitor process but I am not sure it can monitor service/daemon ?

Looks like the manual advices against it.
There is an answer to a similar question which provides a workaround.
Anyway, I would try to find a way to have that service stay in the foreground.

Related

Remotely check on an app's status in pm2 from a website?

I'd like to check the status of an app registered with pm2 remotely such that other web-based monitoring services can give us a notification when something breaks.
Are there any options available to remotely check the status of a process in pm2 remotely? One possibility is to have a web script remotely eval() the pm2 status command and look for certain keywords, and make that script accessible on the web for the notification tool. This doesn't seem ideal, though, as we're using an eval command and maybe a regex of that output just to see what is going on.
Any advice?
I wrote a simple web interface for PM2.
You can simply start a websocket connection to /logs and get your application(s) stats updates such as status, uptime, cpu usage, memory usage, restarts in realtime.Feel free to use and contribute. Cheers!
https://github.com/doorbash/pm2-web
The best option is to use keymetrics. It's free to monitor upto 4 processes(great for development and side projects), easy to link an instance/server but quickly turns out to be very expensive when you scale up.
You could always try switching to other alternatives like upstart or pm2-gui.

Why use nohup when the app can be run as system service?

I put this question on stackoverflow, because I found lots of quesions on the topic here already.
Short introduction
Simply put, nohup can be used to run apps in the background and keeps them running after the user logs off or the terminal or ssh session is closed e.g.
There are many example quesitons here on stackoverflow, like this or that.
My question is simple.
Why opt for nohup, when there are options like upstart, systemd, ... which manage the app as service in a much more convenient way (runlevels, ...)?
Reading the many questions on similar topics, the only option seems to be nohup. Almost never the answer is something like: "... use an upstart script, so it is all handled for you..."
I would mainly go with e.g. upstart, except maybe for a quick and dirty test scenario.
Am I missing something important?
nohup is quick, easy, doesn't require root access and doesn't make permanent changes in the system. That's why many people use it (or try to use it) instead of configuring services.
Running things in the background without any supervision is usually a bad idea, although there are many legitimate use cases which don't fit traditional service model. For example:
Background process might be needed only sometimes, after certain user actions.
More than one instance might be needed. For example: one per user or one per session.
Process might not need to to be running all the time. It just quits after doing its job.
Some real world examples (which use something like nohup and would be hard to implement as system services):
git will sometimes run git gc in background to optimize repository without blocking user work
adb will start its service in background and keep it running until user asks to terminate it
Some compilers have option to keep running in the background to reduce startup times of subsequent invocations
Your understanding is correct, the way those questions were asked the natural answer is nohup - upstart would be the answer to a different question such as How to make sure an application keeps running on Linux

Is it possible to make a process alive during reboot?

I want to make a process alive during reboot. I am thinking that, I can backup all process related information and i will store it on some file. After reboot i will take that data back and by using that i will create a process again. Is my thinking is correct? Please clarify.
Your question is too vague. Can you provide with more information? I can give a basic outline of what is required to run a process on system startup.
Deamonize
A process must be a deamon (it shouldn't run in the context of a terminal) Read deamon process for more information.
chkconfig
Use this to add your deamon to your system startup run levels. sudo chkconfig deamon_name on

Monitor starting/running/ending apps within node.js

Is there a way to monitor starting/running/ending apps within node.js?
Like "You just started LibreOffice Writer!".
It would be nice if any of you cracks could help me with this.
Edit:
I am searching for something that runs in the background and is triggered whenever I run a random application/script/whatever has a system-wide pid.
forever is a daemon manager for node.js that can do this.
http://thechangelog.com/post/6637623247/forever-node-js-daemon-manager
https://github.com/indexzero/forever
Or if you just want to start a process once and be able to manage it, you can use the builtin ChildProcess.
http://nodejs.org/docs/v0.4.9/api/child_processes.html

OpenOffice Daemon Problem

I'm using OpenOffice as a daemon. Sometimes, when the daemon is running a long time, CPU use spikes very high and then openoffice crash. At this point, the open office applicattion don't work and the documents don't be generated.
How can I restart automatically the openoffice daemon when this problem happens? Is there any way to monitor the service or to program a watchdog to handle it?
Thanks in advance, regards.
You may wish to use your distribution's services mechanism; Ubuntu and Fedora, for example, use upstart. Writing an upstart configuration file for your service probably wouldn't be too difficult.
If your distribution doesn't use upstart, you could either run it directly out of your /etc/inittab or use daemontools to monitor your service. (The linux-ha project also has some service monitoring tools, but may have more setup-requirements than you're interested in.)

Resources