4

I'm using bin/console server:run (or app/console for Sf2 directory structure) to develop applications using Symfony2. Unfortunately on multiple systems it dies eventually (usually because of a segfault).

I've tried multiple PHP versions and operating systems (5.5, 5.6 on Ubuntu 14.10 and 15.04, OS X 10.9 and 10.10).

I reported the errors and keep working, but I'm annoyed that I have to restart the server manually every now and then.

I tried to do something like this as my 'build target':

until bin/console server:run -v; do \
sleep 1; \
done

But unfortunately it only works sometimes (I'm yet to determine the reason why it fails to restart the server).

Can you recommend another way to keep this server up preferably without modyfiying the global services/deamons?

Chris Hasiński
  • 2,965
  • 2
  • 25
  • 34

3 Answers3

1

You can use some supervising software to ensure that process is always running. Check out supervisord (http://supervisord.org/)

You'll have to specify similar task to be ran:

[program:server] command=bin/console server:run -v directory=/var/www/symfony-dir autostart=true autorestart=true

More info on flags and examples at http://supervisord.org/configuration.html#program-x-section-settings

And as you said, built in server should not be used in production :)

Mantas
  • 4,259
  • 2
  • 27
  • 32
  • Supervisord is nice, but can I automate it as a build target which I can run and shutdown whenever I want? I don't want for it to have a fixed directory, as each developer can clone the project to a different directory. I don't want *ANY* global configuration at all. – Chris Hasiński Apr 27 '15 at 09:25
  • You can keep separated configuration files on every developer's directory and set supervisord to scan all directories and run programs. – Mantas Apr 27 '15 at 09:42
  • Supervisord also lets you start/stop any program based on name or name pattern. – Mantas Apr 27 '15 at 09:43
  • I will look into that, but I still think this isn't the solution. I was looking towards something simple and I think forever.js https://github.com/foreverjs/forever looks much better for my case :) – Chris Hasiński Apr 27 '15 at 10:16
  • 1
    forever.js looks nice :) – Mantas Apr 27 '15 at 13:10
1

I managed to get this to work by using forever.js.

It wasn't anything fancy, just

forever start server.sh # sh contains bin/console server:run -v

This question proved very helpful, as I could also include assetic watch and a couple other things.

Community
  • 1
  • 1
Chris Hasiński
  • 2,965
  • 2
  • 25
  • 34
0

It's an old question but I had the same problem with new Symfony 4 server on Windows. Here's my solution: https://gist.github.com/banasmat/ef87cd236e248b6287337b6ba30df5c0

  • In the future, please include all relevant code in your post and **don't** just include a link to a code hosting site. Your post should stand alone from any other resource; consider what would happen if that site went down in the future! – DCCoder Sep 18 '20 at 09:30