Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Termux-Services #3460

Merged
merged 10 commits into from Aug 11, 2019

Conversation

@Neo-Oli
Copy link
Member

commented Mar 6, 2019

This is my proposal on how Termux should manage services. It uses busyboxes implementation of runit to manage serivces (or daemons).
You can control the services with sv up <service> and sv down <service>
I've created a init.d stlye script to start the runsvdir daemon using start-stop-daemon . This gets started as a profile.d script.
Termux-services doesn't need to be installed by default. The various packages create their service directories in $PREFIX/var/service. but it will only be executed once termux-services is installed.
In addition I created the sv-enable and sv-disable scripts. sv-enable removes the down file making that particular service autostart when termux starts. sv-disable reverses this.
I've also added a logger which logs all daemon output to $PREFIX/var/log/sv/<service>

I've extended the example services in Busybox and added a new one for openssh. I've written a whole bunch of them here that I would add to the other packages.

What do you think about doing services this way?

Copy link
Contributor

left a comment

Seems like a good idea, but better to just merge the scripts here.

@@ -0,0 +1,8 @@
TERMUX_PKG_HOMEPAGE=https://github.com/Neo-Oli/termux-services/

This comment has been minimized.

Copy link
@joakim-noah

joakim-noah Mar 6, 2019

Contributor

Would be better if those few shell scripts were stored in this Termux repo instead.

This comment has been minimized.

Copy link
@Neo-Oli

Neo-Oli Mar 6, 2019

Author Member

I started it like this, but as I added more scripts I found it easier just to write a short Makefile. I would definitely suggest recreating this repository at https://github.com/termux/termux-services/ instead of my personal space.

@kenneth-Q

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

That sounds good.
I don't recommend to make anything like background services(battery saving and low system resources) but it is a good try.
Also, the repository has been deleted.

@xeffyr

This comment has been minimized.

Copy link
Member

commented Mar 10, 2019

I don't recommend to make anything like background services(battery saving and low system resources)

Any reason that background services consume more resources (including battery) than foreground ?

@kenneth-Q

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

Any reason that background services consume more resources (including battery) than foreground ?

That may be a reason.
On the other hand, one or more service might start itself.In my device, if I run nano and use ctrl+z. Then my phone will be laggy.
by using the htop, I find the cpu core0 is 100% using.
At last, I kill the nano editor.

@xeffyr

This comment has been minimized.

Copy link
Member

commented Mar 10, 2019

if I run nano and use ctrl+z. Then my phone will be laggy.

ctrl-z is for suspending nano by sending SIGTSTP signal. Seems this causing conflict with task manager in your ROM.

But this is not a background process problem. BTW, Android runs most processes in the background, just connect adb and run ps - you will be surprised.

@xeffyr

This comment has been minimized.

Copy link
Member

commented Mar 10, 2019

Then my phone will be laggy.

Also, if your phone is multicore, it cannot lag if only 1 core 100 %. To observe lags, you should have nearly all cores completely loaded.

But anyway, if stopped process causes 100% cpu usage, then you catched either kernel or ROM bug.

@kenneth-Q

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

But anyway, if stopped process causes 100% cpu usage, then you catched either kernel or ROM bug.

Oh, I get it. My phone has 4 cores.

@Neo-Oli

This comment has been minimized.

Copy link
Member Author

commented Mar 11, 2019

@kenneth-Q Also, this feature is entirely optional, so if you're concerned about battery life you can just not use it. I suspect most people wont as they just occasionally use Termux for a few commands at most. But some of use have multiple services like crond, sshd and nginx running at all times, so it's convenient to have a process supervisor around.

@kenneth-Q

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

That OK.
But reference to Debian service. You must ensure that only one instance will work on multiple sessions and widgets.
On the other hand, I hope no packages will depend on it but it should be a recommendation of package. (Like sshd dropbear)

@Neo-Oli

This comment has been minimized.

Copy link
Member Author

commented Mar 11, 2019

@kenneth-Q start-stop-daemon does exactly that. Only one instance of runsvdir is ever running, regardless of how many sessions are opened.

@kenneth-Q

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

Thanks for your comment.
I think it is a nice job.
At last, can you modify the name and usage of the command as same as service(Debian: init-system-helpers)? If you do so, our user may easy to get it started. It just a suggestion, you can choose.
LOL

@Grimler91

This comment has been minimized.

Copy link
Member

commented Mar 11, 2019

@kenneth-Q I think users can read the manual/wiki/help message and figure the syntax/options out themselves. Termux isn't debian so trying to mimic debian would be kinda pointless

@Grimler91 Grimler91 force-pushed the Neo-Oli:termux-services branch from a8bfa27 to 2bd9533 Jul 27, 2019
@Grimler91 Grimler91 merged commit c0ab975 into termux:master Aug 11, 2019
0 of 4 checks passed
0 of 4 checks passed
Build TERMUX_ARCH:aarch64 Task Summary
Details
Build TERMUX_ARCH:arm Task Summary
Details
Build TERMUX_ARCH:i686 Task Summary
Details
Build TERMUX_ARCH:x86_64 Task Summary
Details
@Grimler91

This comment has been minimized.

Copy link
Member

commented Aug 11, 2019

Merged now, will look at adding more service scripts with time.

@xeffyr xeffyr removed the WIP label Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.