monit : reboot server on failed health check - monit

I am trying to get monit to reboot a server if something catastrophic happens, this is to deal with some very experimental stuff we are doing with docker. Ideally I would be able to do
then exec "reboot now"
or
then exec "/var/reboot_now_script"
but they fail to work. Is it possible to restart the server with monit?

Yes, we use this format and it works for us:
then exec "/sbin/shutdown -r now"

Related

Ubuntu Server - Not able to run server in background

I am running server for Rimworld on RapsberyPi 4B.
I have problem with running it in background, when i start the server:
./Open\ World\ Server
Everything starts but name of CMD is the name of the server and when i close the CMD window server will stop.
I´ve tried many things like & after the command, nohup and others. Also I´ve tried pm2 as it is running my discord bot, but everything that I´ve tried is stil saying that Open World Server is "Stopped".
So what i need is:
Run this server in background
Start this server after restart automatically.
Thanks everyone for help :)
So I have found the solution.
I´ve tried pm2 many times but never this way.
nano
#!/bin/bash
Command you want to be executed. In my case
./Open\ World\ Server
Save this like run.sh or whatever.
After that simply do this
pm2 start run.sh
And that is all you need. You can do the same way with minecraft server or other things you want to run in background and start with reboot of your Pi or other devices.

Rundeck - reboot server job

I have a rundeck job that reboots a server, it sends the command "sudo reboot". This works and the server is rebooting.
The problem is that rundeck doesn't get a signal back so the job fails.
Is there a way to make this work and get a complete signal back in rundeck?
Perhaps wrap your command in a script, background the reboot operation, and return 0? I'm doing something similar with a set of development VMs, but I'm using virsh. I don't see why this couldn't be done with a physical server:
#!/bin/bash
ssh rundeck#yourserver sudo reboot &
exit 0
You may need to experiment a bit with the ssh options (perhaps '-f' and/or '-n') to get this to work properly.
Well playing around now I just used as Local Command step:
ssh ${node.username}#${node.hostname} "reboot & exit"
The return code is ZERO and everybody is happy.

How can I start go server permanently?

I've got problem with my Go server.
When I'm connected to my NAS via SSH and do ./gogs web, the server is starting. But when I close the SSH connection, the server is stopped.
How I can start my Go server permanently?
You have scripts in gogs allowing you to launch the server as a daemon:
scripts/init/debian/gogs (recently fixed with issue 519)
scripts/init/centos/gogs
That would allow the process to remain while the session is closed.
You have other options in issues 172.
This is not a Go-specifioc problem, what is happening is that the Go program is still attached to your terminal and when you log out, the kernel will trigger a SIGHUP to every binary still connected to that terminal session.
Your best option is probably to use nohup ./gogs web.
Second-best option would be to rewrite main, so that it intercepts and handles SIGHUP, stopping it from killing your program. However, doing so requires handling quite a few things properly (you really should close stdin, stdout and stderr; make sure all your logging is done through the log library, ...)

Strange Vagrant / SSH Connection Behaviour

I'm running some Capistrano & Chef tasks on some local vagrant VM's. I can SSH into these boxes normally from the command line.
When I try to run some Capistrano tasks, I will always get the following error the first time I run the Cap task:
connection failed for: 192.168.0.220 (Errno::ECONNRESET: Connection reset by peer)
It will occasionally fail a second time too. But then when I run it again, it works! This behaviour makes no sense to me and I haven't the slightest idea how to troubleshoot.
Any help you could provide would be appreciated!
I faced the same issue before, The Problem is faced was the machine didn't have enough resources to execute tasks.
I increased ram to the machine, everything started working again.

Kill localhost:3000 process from Windows command line

So im using ruby on rails in windows (i hear you all spitting your coffee onto the screen), its only a short term thing. (using ubuntu at home) So i tried to fire up webrick this afternoon and i get the error message
TCPServer Error, only one usage of each socket address is normally permitted
So it seems as if port 3000 is still running from last week? My question is how do i kill the process from the Windows command line. normally i have to press ctrl and pause/break in windows as ctrl c is not working which is only killing the batch process it seems..
Any solutions welcomed
Edit
So it seems as if
tasklist
will give me the list of processes, but where do i find the process for running the webrick server?
ruby.exe is not listed as a running process
Try using netstat -a -o -n to determine the pid of the process running on port 3000. Then you should be able to use taskkill /pid #### to kill whatever process is running on that port.
Probably not the most graceful way to do it, but I think it should work.
EDIT
You'll probably have to also use the /F flag to force-kill the process. I just tried it on my local machine, and that worked fine.
Go into rails_project\tmp\pids and delete the .pid file in there.
run:
rails server