Unicorn, RVM and Mac OS X Leopard - macos

I am trying to set up a small web server on my old mac mini G4 at home using the technologies mentioned in the title. I have learned that to serve anything on port 80, the server has to be started with sudo. Since I am using RVM to manage my Ruby Gems, I use rvmsudo to start the server.
I have created a user for running the server, and I can start the server by logging in via SSH and typing 'rvmsudo unicorn -p 80'. But of course when I close the connection the process is terminated, so this is obviously not the way to go.
What is the 'right' way to set up a server on Mac OS Leopard? Keeping in mind that I would like to keep using RVM to manage my gems. I would also like the server to start running automatically when the computer is booted.

you could use the tool GNU screen
http://www.gnu.org/software/screen/
and detach the screen, so the processes will continue running.
alternatively, you could try if this command does the trick:
rvmsudo unicorn -p 80

Related

Lost control over my MariaDB installation

I installed MariaDB on my mac with Macports but lost control over it, mysteriously. I can list the processes and I can login using a user with no privileges. But if I try to stop the database using the usual macports command (sudo port unload mariadb-10.1-server) I get the following error:
/opt/local/etc/LaunchDaemons/org.macports.mariadb-10.1-server/org.macports.mariadb-10.1-server.plist: Could not find specified service
I've tried installing and uninstalling but this doesn't change. How can I do a fresh install of MariaDB on my mac?
Perhaps you inadvertently installed another version of mariadb-server? You can check with:
port echo active |grep mariadb-
It is also possible that the server was started without using launchd and so can't be stopped with the command you were using. You can check with:
sudo launchctl list |grep macports
'org.macports.mariadb-10.1-server' will be in the list if it is running under launchd.
I've deleted the directory where this installation was and reinstalled from Macports. That solved the problem.

How to find where the memcached on Mac OS is installed?

How to find the location of the installed Memcached server on mac, which is installed using the MacPorts tool?
I want to restart the Memcache server, in verbose mode.
This Memcache server is automatically getting restarted, even though I killed it.
Memcached from MacPorts installs a launchd plist file. If that is loaded, launchd will always restart memcached when it notices it is terminated (this is default launchd behavior).
Use sudo port load memcached/sudo port unload memcached to activate/deactive this launchd plist.
If the plist is unloaded, you can manually start memcached using the binary. You can find the binary using port contents memcached | grep -E /s?bin/.

System commands dont work when running over passenger

I have a sinatra app with a page that shows some information about the application. Some of which is generated by running commands on page load. Everything works fine on my MacBook when running in unicorn and everything works fine on the production server when running in unicorn but swap to Apache/Passenger and suddenly the commands start returning nil.
For example to get a list of committers I use:
comitters = `cd /path/to/app && git shortlog -s -n`
This works perfectly until run in the apache/passenger setup.
Is there some option within passenger that disables system commands?
The problem lies in your $PATH environment variable, which the system uses to look for commands. You run Unicorn from the shell don't you? So Unicorn inherit $PATH from your shell. But app processes started from Phusion Passenger are started from Apache/Nginx, which in turn are usually started from some system init service, which have completely different environment variables than your shell. Read http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger/ for a solution.

Installing a daemon for Mac OS X

I created a daemon for running into Mac OS X platform. I made an installer using PackageMaker and the Daemon is installed without problems. It seems that after the installation has finished, I need to reboot the system in order to have the daemon running. I am wondering if I can load and start the Daemon without forcing the reboot?... I have some ideas about it but not sure if is the right way, for example:
Using a shell script that invoke the command: $sudo launchctl load /Library/LaunchDaemons/myService.plist
Using ServiceManagement.framework to manage privilege escalation on the application that will be using the Daemon while is running so the App can if necessary install and load de service. I have to say that the work of the service is required only when a Cocoa App is active.
If any better idea please let me know it people. :D
You should add the daemon load command in the postinstall script of your package (Your Option 1). Anyway, the daemons do have launch-on-demand options so your daemon will only be loaded only if your app requests to load it.

Cannot stop Tomcat6 installed via Macports in Mac OS X 10.7.3

I am using Mac OS X 10.7.3. I installed tomcat6 via macports 2.0.4. I put the tomcat6 location in myeclipse for spring 10 server configuration. Everything was fine so far.
Then I tried to start it in myeclipse. It could not start, saying something like 8080 port is already in use.
Then I went to terminal.
ps aux | grep tomcat
4 process showed up. It seemed tomcat6 started automatically after the installation. Then I tried to stop it with
sudo tomcatctl stop
Here came the problem. No matter how I tried, it always says
Stopping Tomcat...(pid ****)............... giving up.
I tried to kill the process but it kept starting tomcat again right after the kill.
How do I stop it and let myeclipse take over it? Any help is appreciated.
Thanks,
Milo
try doing sudo port unload tomcat6
This command replaced interacting with launchctl yourself, but im unsure if it supports a -w switch which would typically remove the launch daemon were it used with launchctl unload meaning you wouldnt run into the magic restart problem.

Resources