cyfdecyf / cow

HTTP proxy written in Go. COW can automatically identify blocked sites and use parent proxies to access.
BSD 2-Clause "Simplified" License
8.45k stars 1.61k forks source link

[Feature Request] make a daemon (service) for GNU/Linux #318

Open danialbehzadi opened 9 years ago

danialbehzadi commented 9 years ago

That would be great if there is a daemon to control and auto start/stop cow in GNU/Linux with simple command like: # systemctl start/stop/reload/restart/status cow.service

fzerorubigd commented 9 years ago

Already done that for arch, since config is in user home folder, you must use the --user flag for systemctl or use the @yourloginuser hack. Both are available here : https://github.com/fzerorubigd/archlinux-packages/tree/master/cow-proxy

cp cow@.service /usr/lib/systemd/system/cow@.service
cp cow_user.service /usr/lib/systemd/user/cow.service

NOTE : this paths are default for Archlinux, for debian, I have no idea :) Running cow system instance for user account: To reload system systemd modules, execute

systemctl daemon-reload

To start cow, execute:

systemctl start cow@user

To autostart cow on system start, execute

systemctl enable cow@user

Running cow user instance (will used current user account): To reload user systemd modules, execute

systemctl --user daemon-reload

To start cow manually, execute:

systemctl --user start cow

To autostart cow on user login, execute

systemctl --user enable cow
fzerorubigd commented 9 years ago

@danialbehzadi Could you please check them for debian too? if there is any thing about the new jessie, happy to help and get things done :)

cyfdecyf commented 9 years ago

@fzerorubigd thanks for help, I'm also an Arch user before switching to OS X :)

I've provided an init script. Maybe it's not the way to go on Linux system with systemd now.

fzerorubigd commented 9 years ago

@cyfdecyf Debian jessie use systemd by default, so the systemd version is needed. I make a PR when @danialbehzadi confirm it on debian jessie (I have no jessie sandbox available right now.)

danialbehzadi commented 9 years ago

Tested on debian jessie. After systemctl start cow@root I get:

 cow@root.service - COW HTTP proxy service for root
   Loaded: loaded (/usr/lib/systemd/system/cow@.service; disabled)
   Active: active (running) since Mon 2015-05-18 02:35:19 IRDT; 1s ago
 Main PID: 1639 (cow)
   CGroup: /system.slice/system-cow.slice/cow@root.service
           └─1639 /usr/bin/cow

May 18 02:35:19 osmc cow[1639]: 2015/05/18 02:35:19 COW 0.9.5 listen http 0.0.0.0:7070, PAC url http://<hostip>:7070/pac

Seems OK :+1:

But I think it would be better to be unified, with configuration files in /etc/cow/ directory and systemd service controller cow.service

cyfdecyf commented 9 years ago

@danialbehzadi I'll change cow to load config from /etc/cow if there's no ~/.cow and release a new version, maybe on this weekend.

fzerorubigd commented 9 years ago

@cyfdecyf there is two kind of files, one is config/blacklist/withelist and the other is stat. its the good idea to keep the stat inside the home folder (which the user has access to). so must create the .cow folder anyway, and its a good idea to create this folder automatically if its not there.

On Tue, May 19, 2015 at 7:29 PM, Chen Yufei notifications@github.com wrote:

@danialbehzadi https://github.com/danialbehzadi I'll change cow to load config from /etc/cow if there's no ~/.cow and release a new version, maybe on this weekend.

— Reply to this email directly or view it on GitHub https://github.com/cyfdecyf/cow/issues/318#issuecomment-103537734.


http://fzero.rubi.gd

cyfdecyf commented 9 years ago

@fzerorubigd I have to admit the config loading code is a mess #328.

I would like to also put stat file inside the same directory of rc file. If the user running cow is nobody, there maybe no $HOME directory anyway. Of course, user will have to make sure /etc/cow writable by cow process if we do this.

fzerorubigd commented 9 years ago

@cyfdecyf in this case, I can suggest another folder (like somewhere in /var ) for stat folder, the /etc is not a good place to store this kind of things.

ps -and also its a good idea to have an option in rc file to change stat file position. I can do this part, if you are agree with the idea

On Sun, May 24, 2015 at 7:25 PM, Chen Yufei notifications@github.com wrote:

@fzerorubigd https://github.com/fzerorubigd I have to admit the config loading code is a mess.

I would like to also put stat file inside the same directory of rc file. If the user running cow is nobody, there maybe no $HOME directory anyway. Of course, user will have to make sure /etc/cow writable by cow process if we do this.

— Reply to this email directly or view it on GitHub https://github.com/cyfdecyf/cow/issues/318#issuecomment-105022166.


http://fzero.rubi.gd

fzerorubigd commented 9 years ago

Waiting for #328 to fix this one.