396 Commits

Author SHA1 Message Date
dlage
defc40b911 Merge pull request #5 from phemmer/systemd-dependencies
export: fix systemd dependencies
2014-03-17 19:39:14 +00:00
dlage
d205e3ba2e Merge pull request #4 from phemmer/run-nofork
don't fork on 'run'
2014-03-17 19:37:05 +00:00
Patrick Hemmer
67ffbe2aa2 export: fix systemd dependencies
With the previous way systemd services were exported, you had to enable every single process one by one to get the service operational.

Consider the following Procfile:

    web: bundle exec thin start
    worker: bundle exec worker start

Exported with:

    foreman export systemd /usr/lib/systemd/system -a myapp -c worker=3

You will have to perform the following to start the service:

    systemctl enable myapp-web-1.service
    systemctl enable myapp-worker-1.service
    systemctl enable myapp-worker-2.service
    systemctl enable myapp-worker-3.service
    systemctl enable myapp-web.target
    systemctl enable myapp-worker.target
    systemctl start myapp.target

Thats 7 commands, and you have to know the names of each service. Nasty.

With the changes here, you will have to perform the following:

    systemctl enable myapp.target
    systemctl start myapp.target

You can also `systemctl start myapp.target` without enabling as well. Previously if you tried to start `myapp.target` without enabling each individual process it would not work.

---

Additionally, this change also adds the dependency to 'multi-user.target' (the default behavior for all services). This will properly shut down (or start) the app when the system changes runlevels. The previous method did not do this.
2014-02-17 00:40:39 -05:00
Patrick Hemmer
2e5f610b76 don't fork on 'run'
This removes the fork when doing `foreman run`. The fork results in an unnecessary process laying around. The parent process doesn't do anything other than fork and wait for the child to exit.
2013-11-26 00:09:19 -05:00
Michael Granger
20392d98a1 A better fix for #357.
This is a better fix for several reasons:

- It's more portable; the arguments/options to 'ps' vary widely across
  platforms.
- Killing children by forking yet more children (i.e., via backtick) is
  problematic when you're trying to kill processes because of resource
  starvation.
- Processes should not signal processes other than their own children,
  especially in a generic task-runner like Foreman. If the signal
  should propagate, then the sub-process should propagate signals to its
  children itself. There's no way to know what cleanup or preparation
  is necessary for a clean shutdown (e.g., SIGINT/SIGTERM), and
  in what order grandchild processes should be shut down to properly
  release locks, close files, etc.
- foreman-runner doesn't (shouldn't?) create grandchild processes; the
  last thing it does is `exec` the program it's launching, which
  will replace the program of the *current* process with the one
  being started up.
2013-11-05 11:56:13 -08:00
David Dollar
133228f247 Merge pull request #305 from marclennox/master
Add start-stop-daemon export support with upstart
2013-05-03 13:27:54 -07:00
David Dollar
bfba2cad71 Merge pull request #360 from kjwierenga/feature/require-posix-spawn
Feature/require posix spawn
2013-05-03 12:55:16 -07:00
Klaas Jan Wierenga
e245026f65 Fail with an error on Ruby 1.8 when posix-spawn is not present. 2013-05-03 21:44:57 +02:00
Marc Lennox
284503899a Added start-stop-daemon support. 2013-05-03 12:54:08 -04:00
Austin
0fff148fe0 modified to use shellescape instead of gsub 2013-05-03 07:23:25 -07:00
Austin
d19a9aa043 added support for directories with single quotes. fixes #315 2013-05-03 07:22:16 -07:00
David Dollar
c3abaad353 kill the children, not self 2013-05-03 09:54:20 -04:00
David Dollar
0c7b8ddd79 not sure how this snuck in, not in the exporter format 2013-05-03 09:44:25 -04:00
David Dollar
619bd03bb8 Merge pull request #340 from ldmosquera/set_env_var_with_process_name
Set FOREMAN_PROCESS_NAME env var for spawned procs
2013-05-03 06:42:04 -07:00
Klaas Jan Wierenga
baf842cdd4 The wrapped_command has spaces which triggers Ruby to fork a system shell (with /bin/sh -c). This causes orphaned processes on some systems (i.e. Linux). Fix this by splitting the command using String#shellsplit and using ruby's splat operator (*) to pass discrete arguments to spawn. 2013-05-02 16:30:39 +02:00
Klaas Jan Wierenga
75b782b664 Use POSIX::Spawn to make foreman ruby 1.8 compatible and have all specs passing. 2013-05-02 12:39:23 +02:00
David Dollar
da0a9f2de3 Merge pull request #294 from bfulton/master
add systemd export
2013-04-22 20:37:39 -07:00
Leonardo Mosquera
90848e7dea Change FOREMAN_PROCESS_NAME to just PS 2013-04-16 22:31:15 -03:00
David Dollar
0da42cf7d2 0.63.0 2013-04-15 15:33:51 -04:00
David Dollar
403d40b277 Revert "Merge pull request #292 from andrewsmedina/master"
Does not pass tests

This reverts commit 17a8a316b8, reversing
changes made to 9e1d590734.
2013-04-15 15:31:38 -04:00
bfulton
f6b57d7b92 rough draft for systemd export support
http://0pointer.de/blog/projects/systemd.html

This adds support for exporting systemd targets and services.  The
structure is based on the existing upstart support.

Quality is draft and expected to refine in the coming weeks.

One Foremanism that is not respected by these export templates is the
usual log output location, instead stdout and stderr go to syslog.
2013-04-15 14:43:02 -04:00
David Dollar
f1c2347680 Merge pull request #317 from andymorris/fix_deleted_upstart_files
Prevent upstart export from deleting similarly named upstart files
2013-04-14 08:45:21 -07:00
David Dollar
bff554d554 Merge pull request #347 from bkeepers/dotenv
Replace Foreman::Env with dotenv
2013-04-14 08:37:31 -07:00
David Dollar
eaed989c75 Merge pull request #329 from kentaro/permit-underscore-in-procfile
Permit hyphen for command name in Procfile
2013-04-14 08:32:24 -07:00
David Dollar
17a8a316b8 Merge pull request #292 from andrewsmedina/master
circus support
2013-04-14 08:30:17 -07:00
John Griffin
6786f4df39 Revert "Ensure foreman is the process group leader"
This reverts commit 44726e377e.

Conflicts:

	lib/foreman/engine.rb
2013-04-09 17:05:16 +01:00
Brandon Keepers
3abe10e5ab Replace Foreman::Env with dotenv 2013-03-22 10:38:58 -04:00
Leonardo Mosquera
95a1d49e9d Set FOREMAN_PROCESS_NAME env var for spawned procs
This way, processes can identify themselves to metrics logging systems.
2013-03-14 21:34:39 -03:00
David Dollar
2ebb33e049 0.62.0 2013-03-08 14:52:50 -05:00
Michael Granger
169188376b Try to allow children to shut down gracefully
Since signals will no longer be handled once foreman goes into
`terminate_gracefully`, default signal handlers are restored so as
not to cause it to get stuck in an unTERMable state.

This necessitates not using the process group for signalling
except as a last resort, as foreman itself will receive the signals
it sends. This splits `killall` into two methods, one which
signals only processes foreman itself has started, and one which
signals all processes in the process group to try to clean up
more aggressively, and then reworks `terminate_gracefully` to use
them.
2013-03-04 14:05:53 -08:00
Michael Granger
5ab08c608b Add deferred signal-handling (fixes #332).
This uses a thread-local queue and a self-pipe so the code in the
trap blocks is properly re-entrant.

For details, see:

  * http://cr.yp.to/docs/selfpipe.html
  * http://blog.rubybestpractices.com/posts/ewong/016-Implementing-Signal-Handlers.html
2013-03-04 13:28:37 -08:00
Kentaro Kuribayashi
5ef8bbdbe3 Permit underscore for command name in Procfile. 2013-02-21 11:30:59 +09:00
Michael Kaiser
6215f8b3db Fixed a typo in cli options description 2013-02-14 14:45:44 +01:00
Andy Morris
9f3b903085 Prevent upstart export from deleting similarly named upstart files 2013-01-25 00:24:04 -06:00
David Dollar
26bb0ed54e 0.61.0 2013-01-14 08:18:05 -05:00
David Dollar
44002953f6 Merge pull request #277 from pcasaretto/add-timeout-switch
Add timeout switch to CLI - fixes #178
2013-01-14 05:12:12 -08:00
David Dollar
bb2c3a2d04 Merge pull request #264 from asanghi/master
shared_path is set in documentation leading to early evaluation
2013-01-14 05:10:47 -08:00
David Dollar
88cdaacc67 Merge pull request #258 from mclazarus/master
Don't quote shell escaped values.
2013-01-14 05:10:36 -08:00
David Dollar
21dd610eaf Merge pull request #280 from BIAINC/windows/host-support
Strip Windows Line Endings
2013-01-14 05:10:01 -08:00
David Dollar
fe65c7510d Merge pull request #288 from crohr/remove-rubygems-requirement
Remove explicit requirement on rubygems.
2013-01-14 05:08:27 -08:00
David Dollar
cd2c255296 Merge pull request #291 from liveh2o/master
JRuby 1.9 doesn't require posix/spawn
2013-01-14 05:08:10 -08:00
David Dollar
92c1909217 Merge pull request #300 from mattv/output-blank-lines
Don't ignore blank lines in the output
2013-01-14 05:07:31 -08:00
David Dollar
af57bf3d52 Merge pull request #302 from ctrochalakis/process_group_fix
Ensure foreman is the process group leader
2013-01-14 05:07:21 -08:00
David Dollar
443994d3b5 Merge pull request #303 from fxposter/master
Fix for high CPU load. Fixes #260 and #299.
2013-01-14 05:06:44 -08:00
nseo
0d53f6bd6c fix more 2013-01-13 22:10:12 +09:00
nseo
1d2bcdbc56 fix color 2013-01-12 01:10:25 +09:00
Pavel Forkert
aceea1472a Fix #299 and #260
Some processes close their output channels and IO.select keeps
returning them as "readable", while IO#gets returns nil on them, thus
spending a lot of CPU looping through the same reader continuously
2013-01-07 02:30:56 +02:00
Christos Trochalakis
44726e377e Ensure foreman is the process group leader
Foreman should be the process leader before killing processes using
his process group id.

Before that foreman was broken when it was not spawned from a shell.
2012-12-27 15:47:02 +02:00
Matt Venables
61eca5a1d8 Don't ignore blank lines in the output
This fixes the stdout code to ensure that empty lines are outputted.
Many times, these blank lines are intentional, so foreman should not
suppress them.

This fixes #286
2012-12-21 11:12:52 -05:00
Andrews Medina
9325f2ca6d add circus support 2012-11-29 00:15:01 -02:00