![]() 'cd /Users/myusername/myproject/ & script/daemon script/myscript start' $ /usr/bin/env RAILS_ENV=development /bin/sh -c \ $ env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/sh I achieved the former as follows :- $ sudo su I found I needed to change the ownership for my local log directory to match the run_as_username & run_as_group so that it can write and delete the pidfile :- $ sudo chown run_as_username:run_as_group /Users/myusername/myproject/logĪt this point I was in a position to run the start program command either directly in a shell environment mimicking the Monit environment or by running Monit itself. We try to use a standard daemon mechanism for all our background processes and so we put all the pid files in the log directory under the Capistrano shared directory (the project log directory in development). Since Monit is run as superuser, I found I needed to change the ownership of this monitrc file so the Monit process could read it :- $ sudo chown root:wheel /Users/myusername/myproject/monitrc 'cd /Users/myusername/myproject/ & script/daemon script/myscript stop'" \ Stop program = "/usr/bin/env RAILS_ENV=development /bin/sh -c \ 'cd /Users/myusername/myproject/ & script/daemon script/myscript start'" \Īs uid run_as_username and gid run_as_group ![]() Start program = "/usr/bin/env RAILS_ENV=development /bin/sh -c \ With pidfile /Users/myusername/myproject/log/myprocess.pid Note that we run the commands as a specified user and group ( run_as_username & run_as_group) :- check process myprocess Next I created a monitrc containing the start program and stop program commands and put it in my local project root. The advantage of this is that this takes care of adding any PATHs to gem binaries and again we can manage with just the default Monit PATH. This means that at environment load time the bundler gem finds the project gems based on the BUNDLE_PATH specified in the project's. We use bundle install with the -path option to install project gems into a directory under the Capistrano shared directory. We use Bundler, so we need to have the bundler gem installed as a system gem in the default Ruby. In our automated provisioning and deployment solution, we use a Brightbox Ruby Enterprise Edition package which replaces the existing system Ruby, so the default Monit PATH is enough to find the Ruby binaries. Notably it only has the following PATH set: /bin:/usr/bin:/sbin:/usr/sbin. So it seems the best you can do is to create an environment that mimics the Monit environment and try running the commands from there.Īccording to the documentation, the Monit process runs as superuser and has only a very limited set of environment variables. I found I could run Monit in non-daemon mode with verbose logging enabled, but it doesn't show the stdout/stderr generated when it runs your start program or stop program commands. Pm2.Projects Debugging Monit Notes on debugging monit start program and stop program commands.Īt GoFreeRange I recently spent some time debugging a couple of Monit start program and stop program commands, so I thought I'd share some notes I made in case they're of use to anyone else.Īlthough we mainly deploy to Ubuntu, I wanted to be able to debug the commands on my local OSX machine. errback(err, bus) - The bus will be an Axon Sub Emitter object used to listen to and send events.Pm2.launchBus(errback) - Opens a message bus. Elements passed to start are the same than those you can declare in an ecosystem file:Ĭonst pm2 = require ( ' pm2 ' ) pm2. This example shows you how to start app.js with some configuration attributes. Pm2 can also be used programmatically, meaning that you can embed a process manager directly in your code, spawn processes, keep them alive even if the main script is exited.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |