Skip to content
This repository

Upstart pidfile generation #255

Closed
wants to merge 1 commit into from

3 participants

Alfredo Palhares Don't Add Me To Your Organization a.k.a The Travis Bot David Dollar
Alfredo Palhares

Hack that generates a pifile to to /var/run providing a standard way for others tools like monit to check processs status.

  • It fits right in with the current exec
  • Command and grep is an essential package comming preinstalled in all ubuntu machines, so its safe to use it.
  • Does not require any more variable setting.
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged b3448b4 into e06d36b).

Alfredo Palhares

Another more elegant solution would be using the start-stop-daemon script in the exec line. It may have some changes. I can test if you want

David Dollar
Owner

I'd be interested in seeing a pull request that uses start-stop-daemon

Alfredo Palhares

will do

Alfredo Palhares

So after trying a lot, i got to these 2 points that make using start-stop-deamon a problem:
1) Start-stop-daemon can only be run as root (it can start the process itself as any user tough), that means that the upstart script needs to be started as root, that might be an impedance for some use cases.

2) I failed to export ENV vars sucefully with it

Either way I think that should be possible to change location, would you be intrested if i add flag to set the pidfile path ? Since it will cause permission problems for some uses cases (as the travis builder says)

David Dollar
Owner

I would prefer not to add export flags that are specific to a given exporter.

Perhaps you could have this be configurable via environment variable?

David Dollar ddollar closed this April 14, 2013
David Dollar
Owner

Thanks for the pull request, but I'm going to close it in favor of simplicity. I'm trying not to add exporter-specific arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 27, 2012
Alfredo Palhares Upstart pidfile generation b3448b4
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  data/export/upstart/process.conf.erb
9  data/export/upstart/process.conf.erb
@@ -3,3 +3,12 @@ stop on stopping <%= app %>-<%= name %>
3 3
 respawn
4 4
 
5 5
 exec su - <%= user %> -c 'cd <%= engine.root %>; export PORT=<%= port %>;<% engine.env.each_pair do |var,env| %> export <%= var.upcase %>=<%= shell_quote(env) %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1'
  6
+
  7
+post-start script
  8
+  PID=`status <%= app %>-<%= name %> | egrep -oi '([0-9]+)$' | head -n1`
  9
+  echo $PID > /var/run/<%= app %>-<%= name %>.pid
  10
+end script
  11
+
  12
+post-stop script
  13
+  rm -f /var/run/<%= app %>-<%= name %>.pid
  14
+end script
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.