Skip to content

Add doc about how to run worker with systemd#98

Closed
ketchoop wants to merge 2 commits into
php-censor:masterfrom
ketchoop:docs/systemd
Closed

Add doc about how to run worker with systemd#98
ketchoop wants to merge 2 commits into
php-censor:masterfrom
ketchoop:docs/systemd

Conversation

@ketchoop

Copy link
Copy Markdown
Contributor

I didn't check this simple unit with PHPCensor server. Just tried to start it. So, it'll be great if you check this more carefully. And maybe I should write more about the unit and how to start it. Anyway, just leave comments about it and I can change it or just do it by yourself:)

@corpsee

corpsee commented Jul 16, 2017

Copy link
Copy Markdown
Member

Thanks @ketchoop! I will try to test it soon and will write about it in the issue.

@ketchoop

ketchoop commented Jul 17, 2017

Copy link
Copy Markdown
Contributor Author

@ketchoop TODO:
After=network.target
[Install]
WantedBy=multi-user.target

Write about enable.

@corpsee

corpsee commented Jul 17, 2017

Copy link
Copy Markdown
Member

It works if make changes for param ExecStart:

Environment=PHP_PARAM=php-censor:worker
ExecStart=/var/www/php-censor.local/bin/console $PHP_PARAM

@corpsee

corpsee commented Jul 17, 2017

Copy link
Copy Markdown
Member

My full unit config:

[Unit]
Description=PHPCensor Worker
After=network.target

[Service]
Type=simple
Environment=PHP_PARAM=php-censor:worker
ExecStart=/var/www/php-censor.local/bin/console $PHP_PARAM
Restart=always

User=web
Group=www-data

[Install]
WantedBy=multi-user.target

@ketchoop

ketchoop commented Jul 17, 2017

Copy link
Copy Markdown
Contributor Author

@corpsee why does it need this Environment=PHP_PARAM=php-censor:worker?

@corpsee

corpsee commented Jul 17, 2017

Copy link
Copy Markdown
Member

I don't realy know, but console param php-censor:worker doesn't set without Environment.

@ketchoop

ketchoop commented Jul 17, 2017

Copy link
Copy Markdown
Contributor Author

It works for me.

[Unit]
Description=PHPCensor Worker
After=network.target

[Service]
Type=simple
ExecStart=/your/path/bin/console php-censor:worker
Restart=always

[Install]
WantedBy=multi-user.target

Could you restart it and show me last logs from journalctl -u unit-name.service

@corpsee

corpsee commented Jul 17, 2017

Copy link
Copy Markdown
Member

It's strange, but now it works. I guess I overconfigurated somewhere 😄

@ketchoop

Copy link
Copy Markdown
Contributor Author

@corpsee but what about User and Group? Is it OK for you?

@corpsee

corpsee commented Jul 17, 2017

Copy link
Copy Markdown
Member

My full config now:

[Unit]
Description=PHPCensor Worker
After=network.target

[Service]
Type=simple
ExecStart=/var/www/php-censor.local/bin/console php-censor:worker
Restart=always
User=web

[Install]
WantedBy=multi-user.target

@corpsee

corpsee commented Jul 17, 2017

Copy link
Copy Markdown
Member

And it would be great if we had a unit config to start a few workers simultaneously. I guess we should use Type=forking and LimitNPROC=n, but I am not sure.

@ketchoop

ketchoop commented Jul 17, 2017

Copy link
Copy Markdown
Contributor Author

Type=forking means, that process is daemonized by fork strategy. But what you want can be done by hands with systemd specifiers. Something like systemctl start php-censor@1.service. But I have to make little changes and test it.

@ketchoop

ketchoop commented Jul 19, 2017

Copy link
Copy Markdown
Contributor Author

@corpsee I think, the best and simple way to run several workers is just copy more units with different. I can add docs about this way. I need your opinion.

@corpsee

corpsee commented Jul 20, 2017

Copy link
Copy Markdown
Member

@ketchoop It is normal for me. We can update it later if we will have more info.

@corpsee

corpsee commented Jul 24, 2017

Copy link
Copy Markdown
Member

@ketchoop I suggest to merge it now and update when you have additional information. It will OK?

@ketchoop

Copy link
Copy Markdown
Contributor Author

@corpsee just check it and feel free to merge 😃

@corpsee

corpsee commented Jul 25, 2017

Copy link
Copy Markdown
Member

I merged it manualy with rebase. Thanks @ketchoop!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants