Restart passenger synchronously? - passenger

Is there a way to restart a passenger server synchronously?
Running touch tmp/restart.txt will restart the server, but the touch command is asynchronously.

You can follow up the touch tmp/restart.txt command with curl -I http://your-server. That will cause passenger to immediately restart your application.
Is that the functionality you were after?

Related

Cannot permanently disable httpd on Mac 10.14 Mojave after upgrade

I'm running Mojave on a Mac Pro. Prior to this version of the OS I used Apple's Server app to manage Apache/httpd. Now I can't seem to permanently kill or stop httpd. Something keeps it alive and restarts it even when I do the following as root...
launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
apachectl stop
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
apachectl -k stop
httpd (no pid file) not running
If I 'killall httpd' it just comes back. If I kill the main root httpd process in Activity Monitor, it comes right back. Restart the computer, it's still running.
I just want to permanently kill httpd so I can do an alternate installation, possibly with brew or on another machine. I don't want it running and I don't understand what keeps relaunching httpd on me.
The command you mentioned first works for me. I just added 'sudo'
local:~ mac$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
The solution explained in Answer 1 did not work for me when Mojave server.app was installed.
I had to use this:
sudo launchctl unload -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.serviceproxy.plist

How to run auto restart in heroku for ruby scripts

In my Dev box on Nitrous, I am able to run God -c scripts.god -D to restart the two .rb files if they die.
I just run that and the processes for the most part stay alive.
But I cannot do the same in heroku. It seems when I run the god command the .god file does not open and generates an error in heroku.
Question:
How can I run God to restart failed processes in heroku as I do on my development Nitrous environment?
Or is there a recommended alternative way to watch heroku processes and restart them automatically when they fail?
On Heroku you shouldn't need to use a process supervisor like god. If all you need is to ensure your process is restarted if it crashes, Heroku can manage that fine.
It should be as simple as adding two entries in your procfile as workers. https://devcenter.heroku.com/articles/background-jobs-queueing
worker: bundle exec sidekiq
clock: bundle exec clockwork lib/clock.rb
slack_listener: bundle exec ruby lib/slack_bot.rb
You could possibly have issues, if your processing are crashing quite often. Dyno Crash Restart Policy
Your processes should start automatically when you access your website.
However, Heroku does provide commands to manage your processes, check out https://devcenter.heroku.com/articles/dynos for the complete list. E.g., to restart all processes, use the toolbelt command:
heroku ps:restart --app yourappname

What is the command/configuration to run NodeJS/Express app as a daemon?

In SSH if I run:
$ node server
My web app works fine until I close the SSH session. What is the command or configuration needed so that it runs all the time without an active SSH session?
you can run it like:
nohup node server
Or you can install forever.
npm -g install forever
forever start server
If you have multiple nodejs, you can use pm2 to manage them.
Or, use screen or tmux to keep the nodejs running while detach the session.

Can I just kill mongod to stop mongo?

I am very new at Mongo. I am running mongod as described here in Mac OS X. I am running two mongod processes from the command line. If I need to stop the mongod processes I just execute kill <pid of mongod>. Is it the recommended way to stop mongod?
It finally succeeded (Ubuntu 15.04) with
//1.find process by name:
$ pgrep mongo
1350
//2.kill mongod-process
$ kill 1350
This is quite late, but I had same problem now, and I found one easy way :
Esan-iMac:~$mongo admin --eval "db.shutdownServer()"
MongoDB shell version: 2.6.4
connecting to: admin
2015-02-19T10:54:22.574+0200 DBClientCursor::init call() failed
server should be down...
It's giving some odd messages, but it works.
And I made alias-command for running it easy.
alias stop-mongo='/opt/mongo/release/bin/mongo admin --eval "db.shutdownServer()"'
This works at least if you start your mongo manually (e.g. with --fork option).
The accepted answer by Esa is correct. Also, regarding whether using kill is recommended - yes, but with flag -2 or no flag, never use -9. As mentioned in docs.
kill -2 `pgrep mongo`
Alias
alias stopmongo='kill -2 `pgrep mongo`'
Windows
use admin
db.shutdownServer()
For systems with auth enabled, users may only issue db.shutdownServer() when authenticated to the admin database or via the localhost interface on systems without authentication enabled.
Linux
mongod --shutdown
you can also use
kill <mongod process ID>
see http://docs.mongodb.org/manual/tutorial/manage-mongodb-processes/
For year of 2020:
Mongo should be installed through Brew, rather than the old school style on linux: i.e. tar.gz package download/uncompress/configure/run.
In the brew way, if Mongo is installed by brew tap mongodb/brew and brew install mongodb-community, you could do as follows to stop (and disable) it alike Systemd on Linux.
~ brew services list
Name Status User Plist
mongodb-community started zhengxin /Users/zhengxin/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
~ brew services stop mongodb-community
==> Successfully stopped `mongodb-community` (label: homebrew.mxcl.mongodb-community)
terminal$ kill $(pgrep mongod)
this command can help killing the mongod process. sudo pkill -f mongod
Just encountered an issue with "just killing the mongod" in mac...
The mongod is kept running as a service by "launchctl" in mac systems. "just killing" it will kill that service.
Now to use mongo shell we do mongod again, however for other development purpose like connecting from node we need to make sure to run mongod time and again.
Other alternative is shut down the system and start again.
Better Way :
Start using launchctl to manage such services. Here is an example for that :
What is the correct way to start a mongod service on linux / OS X?
The easiest way is Ctrl + C, which worked for me on a blocking bash shell under El Capitan.
If you have configured autostart, killing the process won't help, new one will start immediately. In order to disable autostart, you have to locate the autostart file first. You can try to find the file using e.g.
find / -name "mongodb.plist" or locate "mongodb.plist"
After the file is found, remove the autostart config using (you can try without sudo first, it's not needed if you have done the installation using Homebrew):
sudo launchctl unload -w <file>
If you want to kill the process anyway and it's not using autostart, remember not to use kill -9 <PID>, it can damage the db. kill -1 <PID> or kill -15 <PID> should be safe options.
https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/
official guide
remember not to use kill -9
otherwise maybe you need to remove lock file in dbpath

why my nginx service can not be stopped on my mac?

I installed nginx on my mac lion by using homebrew. When i type command:
nginx -s stop
the service is launched again in a second. how can i stop it?
If you installed the LaunchAgent, I believe that will keep the service alive if it's not running.
See launchd.plist man page
You can try running launchctl stop org.nginx.nginx or remove the
<key>KeeyAlive</key>
<true/>
bit from the plist (~/Library/LaunchAgents/org.nginx.nginx.plist)
Update
Looks like the only way to stop the daemon is to unload the LaunchAgent:
launchctl unload ~/Library/LaunchAgents/org.nginx.nginx.plist
/usr/local/opt/nginx/bin/nginx -g daemon off

Resources