Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Additional helper commands to control PHP's built-in web server#11311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromxabbuh:issue-10827
Sep 22, 2014

Conversation

@xabbuh
Copy link
Member

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#10827
LicenseMIT
Doc PRsymfony/symfony-docs#4005

Basically, both theserver:status andserver:stop wouldn't be really reliable if you had stopped the web server by, for example, killing the process. But honestly I don't know how to platform-independently determine if a process is still running given its PID. Maybe such a way could be a good improvement for the Process component.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

please revert this change

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Without this change I wasn't able to prefix thePHP_BINARY call withexec. Do you have any idea how to handle it then?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@romainneutron To be more precise: The command that should be executed leading to a "Command not found error" actually is something like:

'exec''/usr/bin/php' ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Either we could implement a new feature in the process builder, either you can build the command manually instead of using the ProcessBuilder, but you can not decide to unescape the first argument.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Of course, you're right. I first thought that it doesn't make sense to escape the command name. But that's obviously not always true. What do you think about adding a method likeuseExec to theProcessBuilder class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That would be indeed a nice feature. Please open a new PR for this feature as it would be easier to review this new feature in a separate thread

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I created a pull request for this (see#11335).

@xabbuh
Copy link
MemberAuthor

Both theserver:status andserver:stop commands have to rely on the fact that theserver:status command terminates the proper process. The usage ofexec is required for this to work as expected. Thus,#11335 or a similar solution needs to be merged first (currently, this change is based on the modifications made for#11335).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The server process could have crashed. You could check if the server sends HTTP responses.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good idea. That could be done relatively easy.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The lock file is now removed if the server process terminated before.

@xabbuh
Copy link
MemberAuthor

I modified this a bit. The pull request is no longer based off#11335. Instead the script that is executed by thestart:start command is built manually which was way easier than I had expected.

@xabbuh
Copy link
MemberAuthor

Any thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This var is unused in the string.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Removed it.

@fabpot
Copy link
Member

I've not tried it but it looks good to me.

@fabpot
Copy link
Member

@romainneutron should give you some feedback soon...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

3000 seconds is very long timeout, I rather suggest a short one, 1 second should be enough.

Moreover, this method should return a boolean and close the socket resource once it has been created

@romainneutron
Copy link
Contributor

It would be nice to add correct exitcodes (0 on success, other codes in case of failures)

@xabbuhxabbuhforce-pushed theissue-10827 branch 2 times, most recently from4fbf128 to459a97eCompareSeptember 3, 2014 08:48
@xabbuh
Copy link
MemberAuthor

@romainneutron I added 1 where necessary. 0 is the default behaviour. Do you think it makes sense to return 0 explicitly?

@romainneutron
Copy link
Contributor

No need to return 0 in case the command was successful

@lyrixx
Copy link
Member

The lock management could/should use#10475 (but it's not yet merged)

@xabbuh
Copy link
MemberAuthor

You can then have another look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If it failed, this call would fail. You should use instead:

if (false !==$fp = @fsockopen($hostname,$port,$errno,$errstr,1)) {fclose($fp);returntrue;}returnfalse;

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Oh yes, that's true.

@xabbuhxabbuhforce-pushed theissue-10827 branch 2 times, most recently frombde1b5e toe796bacCompareSeptember 3, 2014 08:59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Let's add a check: If the server could not be started, let's display an error

if (!$process->isRunning()) {$output->writeln('<error>Unable to start the server process</error>');unlink($lockfile);return1;}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this would trigger an error in case the address is not in the right format (for examplerandomstring would trigger anUndefined index notice

To avoid that, you can use:

explode(':',$address) +array(8000);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

or better, ensure the passed argument matches a regular expression

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not really, there wouldn't be any server running with this address. So, there is no lock file andisServerRunning() would never be called (see line 48).

@xabbuh
Copy link
MemberAuthor

I addressed your other suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$pid argument does not seem to be used withsprintf

@xabbuhxabbuhforce-pushed theissue-10827 branch 2 times, most recently from28afe29 to74c993cCompareSeptember 9, 2014 08:16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It should be good to add a call toposix_setsid() here to avoid zombie process.

if (posix_setsid() <0) {return1;    }

@xabbuh
Copy link
MemberAuthor

Thanks for the feedback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

might be nice to display a nice message in case it happens likeUnable to set the child process as session leader

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

done

@romainneutron
Copy link
Contributor

I'm 👍 on this one (once my last comment would be addressed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

justif as the previousif returns

@xabbuhxabbuhforce-pushed theissue-10827 branch 2 times, most recently from8464681 tobd58bcbCompareSeptember 9, 2014 09:51
@xabbuh
Copy link
MemberAuthor

Any other opinion on this?

@fabpot
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commitb601454 intosymfony:masterSep 22, 2014
fabpot added a commit that referenced this pull requestSep 22, 2014
…l PHP's built-in web server (xabbuh)This PR was merged into the 2.6-dev branch.Discussion----------[FrameworkBundle] Additional helper commands to control PHP's built-in web server| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#10827| License       | MIT| Doc PR        |symfony/symfony-docs#4005Basically, both the ``server:status`` and ``server:stop`` wouldn't be really reliable if you had stopped the web server by, for example, killing the process. But honestly I don't know how to platform-independently determine if a process is still running given its PID. Maybe such a way could be a good improvement for the Process component.Commits-------b601454 new helper commands for PHP's built-in server
@xabbuhxabbuh deleted the issue-10827 branchSeptember 22, 2014 12:45
fabpot added a commit that referenced this pull requestOct 9, 2014
…mands (xabbuh)This PR was merged into the 2.6-dev branch.Discussion----------[FrameworkBundle] add changelog entry for web server commands| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |I just noticed that I forgot to add a changelog entry in#11311.Commits-------292088f add changelog entry for web server commands
weaverryan added a commit to symfony/symfony-docs that referenced this pull requestOct 19, 2014
…ilt-in web server in the background (xabbuh)This PR was merged into the master branch.Discussion----------[Cookbook][Web server] description for running PHP's built-in web server in the background| Q             | A| ------------- | ---| Doc fix?      | no| New docs?     | yes (symfony/symfony#11311)| Applies to    | 2.6+| Fixed tickets |Commits-------3caec21 description for running PHP's built-in web server in the background
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@xabbuh@fabpot@romainneutron@lyrixx@cordoval@GromNaN@stof

[8]ページ先頭

©2009-2025 Movatter.jp