Google Groups

Re: [play-framework] Re: [2.0] Start an application as a background process


Ben McCann May 10, 2012 12:36 PM
Posted in group: play-framework
It's super easy to get it up and running.  You just add a program section like the one below to your supervisord.conf with the command pointing to the start script from "play dist".  Then your app will be brought back up whenever the machine is rebooted or the app crashes, etc.  You can use the supervisorctl command to do things like "supervisorctl restart myapp".  Let me know if you have any other questions.

[program:myapp]
user=myuser
command=/play-dist-directory/start -Dconfig.resource=prod.conf -Dlogger.resource=logger-prod.xml -Dhttp.port=8201
stderr_logfile=/log-directory/stderr.log
stdout_logfile=/log-directory/stdout.log



On Thu, May 10, 2012 at 12:05 PM, Ike <ike...@gmail.com> wrote:
Hi Ben,

I've seen you mention this a couple of times already and I'm curious about it. Could you share a bit more detail on how you use Supervisor for this? It would be nice to see some sample working code since the site feels very academic to me.

I've been using very simple shell scripts for this and I'm interested in learning how supervisor could improve this.


On Thursday, May 10, 2012 10:38:01 AM UTC-4, Ben McCann wrote:
I use supervisor to run my Play app and would highly recommend checking it out.


On Thursday, May 10, 2012 7:31:15 AM UTC-7, Guillaume Bort wrote:
Sorry but it works, and it is the proper way of doing it. We are using
this for Heroku deployment (and I use it personally for all my Play
2.0 deployment).

So, again, run:

$ play stage
$ target/start


On Thu, May 10, 2012 at 1:27 PM, Justin <ppa...@gmail.com> wrote:
> It did not work, Guillaume.
>
> So I just fix the framework source a little bit.
>
> pull request:
> https://github.com/playframework/Play20/pull/295
>
> ticket:
> https://play.lighthouseapp.com/projects/82401-play-20/tickets/457-start-an-application-as-background-process
>
> Please review it, Guillaume.
>
> Thanks,
> Justin.
>
> 2012년 5월 10일 목요일 오후 6시 50분 39초 UTC+9, Guillaume Bort 님의 말:
>>
>> use `play stage` and then run `target/start` instead.
>>
>> On Thu, May 10, 2012 at 11:49 AM, Justin <ppa...@gmail.com> wrote:
>> > 'play start' will make me happier because i need to modify the script to
>> > use
>> > 'dist' with Capistrano. :)
>> >
>> > Anyway, I will keep your tip for the last resolution, biesior.
>> >
>> > Thanks.
>> >
>> >
>> >
>> > 2012년 5월 10일 목요일 오후 6시 4분 57초 UTC+9, biesior 님의 말:
>> >>
>> >> It makes no sense to run application in production via console as it
>> >> eats
>> >> some resources as well, better prepare standalone application with dist
>> >> task: http://www.playframework.org/documentation/2.0.1/ProductionDist
>> >>
>> >> Didn't meet any problems with nohup starting dist application yet.
>> >>
>> >> There is also current topic about starting app on Ubuntu, there are
>> >> some
>> >> other solutions suggested:
>> >>
>> >> https://groups.google.com/forum/?fromgroups#!topic/play-framework/G5Tsu3CF4os
>> >>
>> >> W dniu czwartek, 10 maja 2012 10:32:27 UTC+2 użytkownik Justin napisał:
>> >>>
>> >>> Hello, team.
>> >>>
>> >>> I am wondering how an play 2.0 application starts as a background
>> >>> process.
>> >>>
>> >>> As you know, the app will remain in background when typing CTRL + D
>> >>> right
>> >>> after typing 'play start'.
>> >>>
>> >>> But it is not suitable for me because I start my play 2.0 application
>> >>> with a script rather than type 'play start' myself.
>> >>> More specifically on the script, I use Capistrano.
>> >>>
>> >>> I have tried to type command like 'nohup play start', but ended up
>> >>> facing
>> >>> Java exception as follows.
>> >>>
>> >>> [error] java.io.IOException: Bad file descriptor
>> >>> [error] Use 'last' for the full log.
>> >>>
>> >>> I can ignore the error log but Capistrano can't. It's because the
>> >>> nohup
>> >>> command exists with an error, which results in 'failed' status of
>> >>> Capistrano.
>> >>>
>> >>> I am considering deploying the app to many servers, so I can't help
>> >>> but
>> >>> using a deploy tool like Capistrano.
>> >>> It seems that this problem faces the play developers who should handle
>> >>> many servers.
>> >>>
>> >>> Give me some advice.
>> >>>
>> >>> Thanks,
>> >>> Justin.
>> >>>
>> >>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "play-framework" group.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msg/play-framework/-/AGwMOlwp0vYJ.
>> >
>> > To post to this group, send email to play-fr...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > play-framewor...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/play-framework?hl=en.
>>
>>
>>
>> --
>> Guillaume Bort
>
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/0RHkiNzx6B4J.
>
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.



--
Guillaume Bort

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/eWz9HnfpZ14J.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.