OpenOffice Daemon Problem - linux

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.)

Related

Can I monitor daemon/service with supervisord?

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.

Programmatically start systemd service or test if service running

I need to start a service and (later) detect if it running from within a C++ program. Is there a simpler approach than invoking systemctl with suitable arguments and parsing the output?
The source of the service is entirely under my control. (Currently it is written in bash, but a C++ wrapper is entirely possible.)
(I've had a brief look at DBus - it is clearly very powerful, but fails the "simpler" test.)
The source of the service is entirely under my control. (Currently it is written in bash, but C++ is entirely possible.)
The code is for an embedded device running a variant of Debian Jessie. Portability is not a major concern (but obviously the answer will be more useful to others if it is portable).
Most programs are written with the other way in mind (even in pre-systemd days).
Typical services (those having and started with a single server process) are writing their PID (as an ASCII number on a single line) in some /var/run/foobar.pid file at their startup. If you adopt such a convention in your service, you can read that file using fscanf then check that the process is running with kill(pid, 0); (of course, you cannot be certain that it is the same service, but it probably would be).
I have right now more than 20 files matching /var/run/*.pid, notably /var/run/sshd.pid & /var/run/atd.pid
So, assuming you can improve the code of your service FooBar (if that functionality is not there), change its code to write its pid into /var/run/foobar.pid; this is a documented convention.
If you can change the service, you might have it providing some ping or nop functionality; so you would add to it some RPC facility which justs check that the service is running (and could also give some additional information, like the version of the program, etc.). Most existing Linux services have such feature.
Why not flip the problem around? No parsing would be needed.
ttm.update.service will do the following.
systemctl stop ttm.service
systemctl disable ttm.service
#do you update here
#if the service configs changed do
systemctl daemon-reload
systemctl enable ttm.service
systemctl start ttm.service
ttm.service would never have to worry about the updater, it just runs and do it's job.

What are the advantages and disadvantages of using the upstart script or forever script in a context of running node.js scripts ??

I am a node.js developer. I use Amazon ec2 to deploy my node.js apps.
I want to have my node.js service running permanently - restarted if it fails for any reason.
I came across 2 tools . Forever and Upstart
Is there any advantages of using one over the other ?
Is there any other tool which is better ?
Upstart is a system service controller, similar to SysV Init and will start/stop/restart essentially any service registered for it, Node.js-based or not, and it will also automatically start services on system start for you. But Upstart is essentially specific to Ubuntu, and Upstart-specific services won't run on other Linux distros.
Upstart has a SysV Init compatibility layer that you could target,instead, to maintain as broad of a compatibility layer as possible.
Forever is a Node.js application that monitors and restarts other Node.js applications as needed, and as defined by its configuration JSON. Lots of options and fine-grained control over your service without the effort that would be needed to duplicate it in a custom SysV Init script. However, Forever isn't a system service, so if the server is restarted, you'll have to manually start your forever scripts again.
Beyond that, if all you need is something that will restart your script if/when it crashes, and you don't care about it starting automatically on system start, all you need is a bash script as simple as:
#!/bin/bash
while true
do
node ./myScript.js
done
Just to correct a misleading statement in the accepted answer...it is not true that upstart is an Ubuntu-only technology. See:
https://serverfault.com/questions/291546/centos-6-and-upstart
http://searchenterpriselinux.techtarget.com/tip/RHEL-6-ditches-System-V-init-for-Upstart-What-Linux-admins-need-to-know
http://en.wikipedia.org/wiki/Upstart#Adoption
With that, I think it is a much more compelling solution.

Daemon startup on Debian(existence of /sbin/service)

What is the best way to start a service on Debian through a program? I used to use '/sbin/service start', but I recently came across a system where '/sbin/service' did not exist, so starting the daemon would fail.
copy and customize /etc/init.d/skeleton (e.g. into /etc/init.d/specksyn) and add symlinks from e.g. /etc/rc2.d/S99specksyn to it, etc. etc.

How do I run a serve as daemon on linux?

I created a server using c++ and want to run this server as daemon on linux..
How do I do this?
Thanks in advance...
There are many ways to daemonize a process. It is quite common that server implementations provides a switch to daemonize it at startup.
If you do not wish to implement such a feature, command-line tools exists such as this one : http://software.clapper.org/daemonize/.
I don't mean to sound condescending but did you try a google search, there is a heap of info on this out there, the first link I found: (http://www.enderunix.org/docs/eng/daemon.php)
You can use dup2() on Linux to make the FD's a bit easier to handle.
You may also want to look into using something like inetd to manage your server

Resources