I have written a software that will act as a server to an application I've made. This works perfectly when I run it from the terminal but crashes every time on a very specific action when I run it as an Upstart service. I think it crashes when it reads from a file but it's hard to know using Haskell.

This is how I run it in the terminal (when it works):

cd /srv/MyApp/
sudo -u appServerUser -g appServerUser ./appServer

And this is my Upstart .conf (placed in /etc/init/) (which crashes):

start on runlevel [2345]
stop on runlevel [^2345]

chdir /srv/MyApp/
setuid appServerUser
setgid appServerUser

respawn limit 5 5

exec ./appServer

Have I configured the Upstart incorrectly? Or why does the program behave differently when it should have the exact same privileges and is run from the same place.

I realised I was a bit incorrect about the program crashing. The program doesn't crash but the thread does.

FOUND THE SOURCE: After a lot of minification i realized it crashes when it's trying to read non-ASCII characters. Why it only fails when run as Upstart i beyond me, but I have found the problem and I would say it's a bug in the compiler or in Upstart.

  • Have you looked at the logs (they will be saved by Upstart in /var/log/upstart)? – muru Sep 15 '15 at 16:55
  • Yes, unfortunately no errors are displayed. Only "Client disconnected" is printed by my function that handles threads crashing (see my edit). – SiXoS Sep 15 '15 at 17:06
  • Does your program depend on something in the environment? Maybe some external utility you call assuming your PATH, which a service might not share? – muru Sep 15 '15 at 18:08

There was some problems with chdir and upstart some time ago. Generally upstart was doing some weird stuff with the processess that resulted in ./application being executed not from the directory set by chdir iirc.

Try exec /srv/MyApp/appServer without chdir or exec 'cd /srv/MyApp/; ./appServer' (there will be scope difference for working dir here, but that should not matter in your example)

  • This seamed promissing but unfortunately didn't work. The first method started it in the wrong directory and the second didn't even start it. I think chdir works in my case as I list all the files that's accessed without a problem. – SiXoS Sep 15 '15 at 17:28

Ok, I found the problem. Why is there always such simple answers to such complicated problems. I needed to put:

env LAN=en_US.UTF-8

in the .conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.