- BUGS AND LIMITATIONS
- SEE ALSO
- LICENCE AND COPYRIGHT
panctl - start, stop, and manage daemons, programs, and scripts
The config file should live in ~/.panctl/panctl.conf.
ssh-foo: command: ssh -L 2222:foohost:22 somehost -N description: ssh tunnel for otherhost ssh-bar: command: ssh -L 2223:barhost:22 somehost -N description: ssh tunnel for someotherhost synergy: command: /Applications/synergy-1.3.1/synergys -c /my/synergy.conf -d INFO -f description: synergy keyboard/mouse sharing
Command line options:
# control a specific named daemon panctl -daemon ssh-foo -start panctl -daemon ssh-foo -stop panctl -daemon ssh-foo -stop -force panctl -daemon ssh-foo -restart # control all daemons with 'ssh' in the name panctl -daemon ssh -start # control all configured daemons panctl -all -start panctl -all -stop panctl -all -stop -force panctl -all -restart # monitor the log files (tail -f) of daemons panctl -all -tail panctl -daemon ssh-foo -tail panctl -daemon ssh -tail panctl -daemon ssh -tail -start # start the supervisor process, restarts any enabled daemons that fail panctl -all -supervisor # start the supervisor, only watching the monitoring and rules daemons panctl -mon -rules -supervisor # disable/enable a daemon. when disabled, the daemon will not # start and will not be restarted by the supervisor. panctl -d ssh-foo -disable panctl -d ssh-foo -disable -stop panctl -d ssh-foo -enable panctl -d ssh-foo -enable -start
This script will allow you to configure a list of services (e.g. ssh tunnels, daemons, scripts, etc.) that can be started and stopped apachectl-style. In addition, a supervisor process can be spawned to monitor selected enabled daemons and automatically restart them in the event that they die.
All daemon stdout/stderr is written to ~/.panctl/daemon_name.log, and the pid will be written to ~/.panctl/daemon_name.pid.
This works great for keeping a bunch of ssh tunnels and other scripts and daemons running.
The following options are supported by this command
- -daemon [regexp]
Selects all daemons whose names match the specified regexp.
Selects all configured daemons.
Combine with -start or -stop to start and stop the supervisor process.
When daemons are selected (with the -daemon flag), the supervisor will only monitor the specified daemons.
Note that only one supervisor can be running at a time! If you start a supervisor for a selected daemon, and then start it again for a different selected daemon, only the latter will be supervised.
- -tail [timeout]
Create a File::Tail to display all selected daemons' stdout/stderr log files. The effect is similar to running 'tail -f' on all the log files.
If a timeout is specified (optional), the log files will only be monitored for the specified number of seconds.
When combined with other options, e.g. -start, the log file will be opened before performing any operations, so the output you see will reflect the output of any operations you performed.
Start all selected daemons
Stop all selected daemons by sending them a 'kill -HUP'.
When combined with -force, will send a 'kill -9'
Calls stop() on the selected daemons, followed by start().
Calls disable() on selected daemons. Disabled daemons will no longer respond to start() until enable() is called. If a supervisor is monitoring the daemon, it will no longer be restarted.
Disabling a daemon does not stop any currently running processes. Can be combined with the -stop option to immediately shut down the daemon if it's currently running.
Calls enable() on selected daemons. If the daemon is disabled, it will be enabled.
Enabling a daemon does not start it. Can be combined with the -start option to immediately start the daemon if it's not already running.
Only immediate child processes are tracked. Any processes spawned by launched processes will not be tracked.
The most obvious limitation is probably that backgrounding or doing a fork()/exec() (daemonizing) in executed scripts is not allowed. The pid of any script that fully daemonizes will be lost by Proc::Launcher, and will be considered failed which may lead to the process being restarted.
Don't even try using this with apache. While it is possible to make apache run in a non-daemonized mode, you probably don't want to do it that way.
There is no log file maintenance. If your daemons produce a lot of output, you will probably want to truncate the logs occasionally, e.g.:
echo >> ~/.panctl/daemon_name.log
Alternately you could shut down the daemon, remove or gzip the log file, and then start the daemon back up.
Patches are welcome.
L<Proc::Launcher> L<Proc::Launcher::Manager> L<Proc::Launcher::Supervisor>
Copyright (c) 2008, VVu@geekfarm.org All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.