NSSM daily rotation - logrotate

How to enable on the "daily" rotation. I need to rotate the logs strictly at 00:00 every day.
There is no word about it in the documentation, or i dont understand something.
I have service installation script "install.bat" in which all the parameters related to log rotation:
...
nssm set Server%SNAME% AppStdout C:\Server%SNAME%\Logs\server.log
nssm set Server%SNAME% AppStderr C:\Server%SNAME%\Logs\server.log
nssm set Server%SNAME% AppStdoutCreationDisposition 4
nssm set Server%SNAME% AppStderrCreationDisposition 4
nssm set Server%SNAME% AppRotateFiles 1
nssm set Server%SNAME% AppRotateOnline 1
nssm set Server%SNAME% AppRotateSeconds 86400
nssm set Server%SNAME% AppRotateBytes 52428800
...
the only thing I came up with is calling, from another service, the rotation command:
nssm rotate %Server%SNAME%
and it works, but I think there are better options.
How else to rotate nssm logs every day at a strict time?

No, I don't think it's in capabilities of NSSM. You can specify time between rotations, but it's related to time, since the service is running. It's not cron-like record.

Related

supervisord autorestart max tries?

http://supervisord.org/configuration.html#program-x-section-values says you can use autorestart=true to restart on exit, but doesn't say how to give a maximum amount of restarts (within startsecs) before giving up. Is there a way to do this? Note: I'm not talking about the first startup, but about the event that a program crashes after, say, running fine for 10 days.
According to the docs, autorestart doesn't care about startretries:
autorestart controls whether supervisord will autorestart a program if
it exits after it has successfully started up (the process is in the
RUNNING state).
supervisord has a different restart mechanism for when the process is
starting up (the process is in the STARTING state). Retries during
process startup are controlled by startsecs and startretries.
You should use startretries as well, ex of program configuration:
[program:consumer_example]
command=command example
process_name=%(program_name)s_%(process_num)02d
numprocs=1
autostart=true
autorestart=true
startretries=10
user=USERNAME
As you can see I used startretries with 10, when you not inform into program it uses the default value (3).
I think that you need is to use the startretries parameter..
http://supervisord.org/configuration.html?highlight=startretries#program-x-section-example
best regards

How do you configure rolling logs with wildfly

We are using wildfly and in our wildflyhome/standalone/log directory it's filling up with logs and eventually running out of disc space. I would like to set up rolling logs and know that it's possible but just don't know how to do it. Any help would be appreciated.
If you're on linux just setup a cron job to purge the files.
If you want to use a size rotation that will only keep as many rotations as you tell it you can use a size-rotating-file-handler.
The following CLI command will replace the default periodic-rotating-file-handler with a size-rotating-file-handler which rotates when the log file reaches 50MB and will only keep 10 rotations.
batch
/subsystem=logging/root-logger=ROOT:remove-handler(name=FILE)
/subsystem=logging/periodic-rotating-file-handler=FILE:remove
/subsystem=logging/size-rotating-file-handler=FILE:add(append=true, autoflush=true, named-formatter=PATTERN, max-backup-index=10, rotate-size=50m, file={relative-to=jboss.server.log.dir, path=server.log})
/subsystem=logging/root-logger=ROOT:add-handler(name=FILE)
run-batch

In a /etc/init/script how I capture event for "eth1 is ready" on RHEL 6 in upstarts?

I've tried below, but doesn't work:
1:start on (net-device-up IFACE!=lo and runlevel [2345])
2:start on started network-interface INTERFACE=eth1
I saw the networking service is still be brought up by calling these init.d scripts,
so I doubt on RHEL 6, there is real a "event" from upstart for NIC's up.
anyone has any idea?
I figure it out somehow by:
start on stopped rc RUNLEVEL [2345]
so the upstart job rc(/etc/init/rc.conf) just call all the init scripts by
exec /etc/rc.d/rc $RUNLEVEL
when all the rc scripts done, all the NIC are up, and the job "rc" in upstarts does have a status change and emit status.

Enable PAM configuration (limits.conf) for a running daemon

I'm currently attempting to develop a sandbox using Docker. Docker spawns process through a running daemon, and I am having a great deal of trouble enabling the limits set forth in the limits.conf file such that they apply to the daemon. Specifically, I am running a forkbomb such that the daemon is the process that spawns all the new processes. The nproc limitation I placed on the user making this call doesn't seemed to get applied and I for the life of me can not figure out how to make it work. I'm quiet positive it will be as simple as adding the correct file to /etc/pam.d/, but I'm not certain.
The PAM limits only apply to processes playing nice with PAM. By default, when you start a shell in a container, it won't have anything to do with PAM, and setting limits through PAM just won't work.
Here are some other ways to make it happen!
Instead of starting your process immediately, you can start a tiny wrapper script, which will do the appropriate ulimit calls before executing your process.
If you want an interactive shell, you can run login -f <username> (e.g. login -f root); that will use the normal login process to auto-log you on the machine (and that should go through the normal PAM mechanisms).
If you want all containers to be subject to those limits, you can set the limits on your system, then restart Docker with those lower limits; containers are created by Docker, and by default, they will inherit those limits as well.

Using Monit to monitor a custom daemon

I created a daemon using the System_Daemon pear package. How do I use Monit to restart the daemon when it fails.
I have the following code that was going to place in the monit config gile:
check process merge with pidfile /var/www/merge/merge.pid
group 1000
start program = "/etc/init.d/merge start"
stop program = "/etc/init.d/merge stop"
if failed host IPADDRESS port 80
then restart
if 5 restarts within 5 cycles then timeout
Is that the right way to monitor a custom daemon?
I'd say it looks quite correct.
If you ask, I guess it is because you are facing issues. Can you elaborate?