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

[Experiment] Install Uptime Kuma on Android device #423

Closed
louislam opened this issue Sep 16, 2021 · 19 comments
Closed

[Experiment] Install Uptime Kuma on Android device #423

louislam opened this issue Sep 16, 2021 · 19 comments
Labels
area:documentation Improvements or additions to documentation

Comments

@louislam
Copy link
Owner

louislam commented Sep 16, 2021

(Updated 2023-07-08)

Just for fun, you can use your old Android phone (Android 7+) to monitor website.

  1. Download Termux APK: https://github.com/termux/termux-app/releases/download/v0.118.0/termux-app_v0.118.0+github-debug_universal.apk
    (⚠️ Do not download Termux from Google Play which is too old and not working)
  2. Launch Termux App
  3. (Optional) Install a SSH server, so you can do the following steps on your PC which is more comfortable.
  pkg upgrade
  pkg install openssh
  sshd
  passwd
  1. Run these commands to install Uptime Kuma
pkg upgrade
pkg install clang make python nodejs-lts binutils git

git clone https://github.com/louislam/uptime-kuma.git
cd uptime-kuma
npm run setup           # It may takes a few minutes

node server/server.js
  1. Open a new terminal, type ifconfig to view the IP, and go to http://192.168.1.X:3001 on your PC.

Tested with Snapdragon 652 CPU. The performance is actually good.

However, Android always kill apps unexpectedly. I don't know Android system will kill Termux or not, so it is not a recommended method. Just for fun.

image

image

@louislam louislam added the area:documentation Improvements or additions to documentation label Sep 16, 2021
@Ponkhy
Copy link
Contributor

Ponkhy commented Sep 17, 2021

Just tried it on a Snapdragon 865, it's actually kinda funny and it runs really well! ^^

@absozero
Copy link

absozero commented Oct 31, 2021

This experimental feature does not work anymore.

Tested on a clean termux installation on the motorola g6

The packages necessary are at these versions(btw, git is a package that should be on the list to install as well):

clang is at: (13.0.0-1).
make is at: (4.3-1).
nodejs-lts is at: (16.13.0).
python is at: (3.10.0-3).
git is at: (2.33.1)

After running:
git clone https://github.com/louislam/uptime-kuma.git
And then:
cd uptime-kuma

When running `npm run setup` npm throws this error:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '14.*' },
npm WARN EBADENGINE   current: { node: 'v16.13.0', npm: '8.1.0' }
npm WARN EBADENGINE }
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.

After the warning, npm also throws this error:

npm ERR! Exit handler never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://github.com/npm/cli/issues>
npm ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2021-10-31T06_54_26_188Z-debug.log

The full log is given in this file:
debug.txt

After, even with this error, running `node server/server.js` throws:

Server Type: HTTP
node:internal/fs/utils:344
    throw err;
    ^

Error: ENOENT: no such file or directory, open './dist/index.html'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.<anonymous> (/data/data/com.termux/files/home/uptime-kuma/server/server.js:150:20)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: './dist/index.html'
}

I infer from these errors that Uptime Kuma does not work anymore on android devices, at least for now.

@chakflying
Copy link
Collaborator

@absozero referencing this, it might be a combination of the phone not being powerful enough and we have increased our dependencies use. Probably means unlikely to be fixed in the future.

However, since this is only a failure of npm install, if you are familiar with web dev you might be able to use a more powerful ARM device to build the node_modules, compile the output js, then transfer the whole thing into the phone. But at that point you're better off running it on a raspberry pi anyway.

@louislam
Copy link
Owner Author

Also related to nodejs-lts had been upgraded to NodeJs 16 on Termux. It was working fine when it was 14.

Unfortunately, it seems that there is no way to install Node.js 14 again on Termux.

@absozero
Copy link

@louislam I think that the reason that nodejs-LTS is now 16 is because the official Lts has changed to that. Also, termux follows a rolling release model, making it impossible to downgrade with the package manager. I have installed this version on my production machine and the steps to setup uptime-kuma worked perfectly, so it must be a problem on the side of termux.

@chakflying I dont think the problem is with the phone since it has a snapdragon 600 series CPU. It might be the dependencies since in termux some of them were said to be deprecated. The reason why I even want to put this service on my phone is because it is a different machine from production and will likely stay on longer so if the whole production server goes down I can check and then know when. I dont want to go the extra trouble just to get the service installed, I might just buy a pi. I wanted to use what I already had so I looked into this option. Unfortunate that it does not work

@louislam
Copy link
Owner Author

louislam commented Oct 31, 2021

@absozero I found a workaround. Downgrading to npm 6.X.X solves the issue

npm install npm@6 -g

Also binutils is needed for compiling SQLite

pkg install binutils 

@milindpatel63
Copy link

Can confirm it's working with latest version...

Been running on my old Nextbit Robin running android 11 based LineageOS...

I use Termux Boot to auto start the app on boot and keep wakelock....
I also use Acca app to keep phone's battery between 75-80%...

And I use Tasker to monitor battery levels and CPU temps and send notifications via pushbullet if they get low..

Also, continuous running had some network issues where uptime kuma was giving error name not resolved or some other error, so I just restart the phone using tasker around the same time when I update my docker containers in my server using watchtower...

Working amazing for several months now..

@Kalmai221
Copy link

Is there a way if your not rooted?

@OlegEnot
Copy link

OlegEnot commented Apr 17, 2023

Setup that worked for me (no root):

pkg upgrade
pkg install clang make python nodejs-lts binutils git build-essential
cd ~
mkdir .npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install npm
git clone https://github.com/louislam/uptime-kuma.git
cd ~/uptime-kuma
npm install dayjs --ignore-scripts
npm run setup
node server/server.js

Add kuma autostart at session start:

echo -e '#!/data/data/com.termux/files/usr/bin/bash\ncd ~/uptime-kuma\nnode server/server.js' >> ~/start_kuma.sh
echo 'bash ~/start_kuma.sh' >> ~/.bashrc
Details Termux

Termux App Info

APP_NAME: Termux
PACKAGE_NAME: com.termux
VERSION_NAME: 0.117
VERSION_CODE: 117
TARGET_SDK: 28
IS_DEBUG_BUILD: false
APK_RELEASE: F-Droid

Software

OS_VERSION: 5.4.147-qgki-g001d72709847
SDK_INT: 31
RELEASE: 12
ID: SKQ1.211006.001
DISPLAY: SKQ1.211006.001 release-keys
INCREMENTAL: V13.0.1.0.SKCCNXM
SECURITY_PATCH: 2022-06-01
IS_DEBUGGABLE: 0
IS_TREBLE_ENABLED: true
TYPE: user
TAGS: release-keys

Hardware

MANUFACTURER: Xiaomi
BRAND: Redmi
MODEL: 2201116SG
PRODUCT: veux
BOARD: veux
HARDWARE: qcom
DEVICE: veux
SUPPORTED_ABIS: arm64-v8a, armeabi-v7a, armeabi

@Kalmai221

@Kalmai221
Copy link

Setup that worked for me (no root):

pkg upgrade
pkg install clang make python nodejs-lts binutils git build-essential
cd ~
mkdir .npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install npm
git clone https://github.com/louislam/uptime-kuma.git
cd ~/uptime-kuma
npm install dayjs --ignore-scripts
npm run setup
node server/server.js

Add kuma autostart at session start:

echo -e '#!/data/data/com.termux/files/usr/bin/bash\ncd ~/uptime-kuma\nnode server/server.js' >> ~/start_kuma.sh
echo 'bash ~/start_kuma.sh' >> ~/.bashrc
Details Termux

Termux App Info

APP_NAME: Termux
PACKAGE_NAME: com.termux
VERSION_NAME: 0.117
VERSION_CODE: 117
TARGET_SDK: 28
IS_DEBUG_BUILD: false
APK_RELEASE: F-Droid

Software

OS_VERSION: 5.4.147-qgki-g001d72709847
SDK_INT: 31
RELEASE: 12
ID: SKQ1.211006.001
DISPLAY: SKQ1.211006.001 release-keys
INCREMENTAL: V13.0.1.0.SKCCNXM
SECURITY_PATCH: 2022-06-01
IS_DEBUGGABLE: 0
IS_TREBLE_ENABLED: true
TYPE: user
TAGS: release-keys

Hardware

MANUFACTURER: Xiaomi
BRAND: Redmi
MODEL: 2201116SG
PRODUCT: veux
BOARD: veux
HARDWARE: qcom
DEVICE: veux
SUPPORTED_ABIS: arm64-v8a, armeabi-v7a, armeabi

@Kalmai221

npm contains cached files from old npm version

@louislam
Copy link
Owner Author

louislam commented Jul 8, 2023

Updated the steps, it should works again now.

@Zaid-maker
Copy link
Contributor

Cypress warning platform "android" not supported

@louislam
Copy link
Owner Author

louislam commented Oct 9, 2023

cypress should be dev only dependency, it is not in production. Be sure to install dependencies with npm install --production

@Mypchikov
Copy link

Screenshot_20231207-154849
Not working

@CommanderStorm
Copy link
Collaborator

See #3642 on how to get around playwright not suppoting platforms like freebsd or android

@Mypchikov
Copy link

Screenshot_20231209-003359
Base

@chakflying
Copy link
Collaborator

the server.js file is located in server/server.js. So you can try this:

node server/server.js

@louislam louislam mentioned this issue Dec 9, 2023
2 tasks
@LunarLoom24
Copy link

npm error code 1
npm error path /data/data/com.termux/files/home/uptime-kuma/node_modules/@louislam/sqlite3
npm error command failed
npm error command sh -c node-pre-gyp install --fallback-to-build

@T1MOXA
Copy link

T1MOXA commented Aug 27, 2024

npm error code 1 npm error path /data/data/com.termux/files/home/uptime-kuma/node_modules/@louislam/sqlite3 npm error command failed npm error command sh -c node-pre-gyp install --fallback-to-build

termux/termux-packages#20717 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests