Skip to content

Add doc about how to run worker with systemd#98

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

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

Conversation

@ketchoop
Copy link
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
Copy link
Member

corpsee commented Jul 16, 2017

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

@ketchoop
Copy link
Contributor Author

ketchoop commented Jul 17, 2017

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

Write about enable.

@corpsee
Copy link
Member

corpsee commented Jul 17, 2017

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
Copy link
Member

corpsee commented Jul 17, 2017

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
Copy link
Contributor Author

ketchoop commented Jul 17, 2017

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

@corpsee
Copy link
Member

corpsee commented Jul 17, 2017

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

@ketchoop
Copy link
Contributor Author

ketchoop commented Jul 17, 2017

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
Copy link
Member

corpsee commented Jul 17, 2017

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

@ketchoop
Copy link
Contributor Author

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

@corpsee
Copy link
Member

corpsee commented Jul 17, 2017

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
Copy link
Member

corpsee commented Jul 17, 2017

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
Copy link
Contributor Author

ketchoop commented Jul 17, 2017

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
Copy link
Contributor Author

ketchoop commented Jul 19, 2017

@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
Copy link
Member

corpsee commented Jul 20, 2017

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

@corpsee
Copy link
Member

corpsee commented Jul 24, 2017

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

@ketchoop
Copy link
Contributor Author

@corpsee just check it and feel free to merge 😃

@corpsee
Copy link
Member

corpsee commented Jul 25, 2017

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