Self-host CodePush API Service

Search for a command to run...

No comments yet. Be the first to comment.
Most AI agents that support scheduled tasks have two sources of instruction when a cron job fires: The cron prompt — the task-specific instructions you wrote when scheduling the job The skill — a re

TL;DR Scarp draw result, host on GitHub, retrieve it like API at damacai.hongineer.com. Data Scraping I have previously shared a technique for scraping Da Ma Cai draw result. Now I finally have time t

This is a Bash script that check if the replica (slave) health status. If there is an issue, it will exist with non-zero status. This is useful when used with monitoring tools like [Monit](https://mmo

chmod is a command-line utility used to change the access permissions of file system objects such as files and directories. It allows you to control who can read, write, and execute those objects. Changing Permissions Using Octal Notation Example Usa...
chown changes the ownership of files and directories. This involves modifying the user and/or group associated with a file, determining who has access and permissions. Changing File Ownership to a Specific User Example Usage: chown user file.txt What...
CodePush is a service that enables React Native developers to deploy mobile app updates directly to their users’ devices. Microsoft is retiring this service on 31 March 2025. Fortunately Microsoft open sourced the CodePush server on GitHub, allowing anyone to self-host CodePush server.
CodePush API service consist of 2 components:
API server (https://github.com/microsoft/code-push-server/tree/main/api)
CLI tool for managing CodePush Server (https://github.com/microsoft/code-push-server/tree/main/cli)
This article provides instructions on how to install these 2 components. The setup was performed on CentOS, but it can be easily adapted to other Linux Distro.
CodePush GitHub: https://github.com/microsoft/code-push-server
Prerequisites:
NodeJS installed
NPM installed
Redis server installed and running
Download source code into /opt.
cd /opt
sudo git clone https://github.com/microsoft/code-push-server.git
Copy /opt/code-push-server/api/.env.example to /opt/code-push-server/api/.env and modify it:
Set EMULATED to true, unless you want to setup Azure Blob Storage for storage.
Configure Redis REDIS_HOST, REDIS_PORT, REDIS_KEY.
Build the app.
cd /opt/code-push-server/api
sudo npm install
sudo npm run build
At this point you can test run the API server: npm run start:env. By default the server binds to 127.0.0.1:3000, accepting HTTP requests.
Create /etc/systemd/system/code-push-server.service file with the following content:
[Unit]
Description="CodePush Server"
Documentation="https://github.com/microsoft/code-push-server/blob/main/api/README.md"
After=network.target
[Service]
WorkingDirectory=/opt/code-push-server/api
ExecStart=/usr/bin/npm run start:env
Restart=always
Environment=NODE_ENV=production
# Limit the number of restarts in a short period to prevent excessive resource usage
RestartSec=10 # Wait 10 seconds before restarting
LimitNOFILE=65536 # Increase file descriptor limit (important for production)
[Install]
WantedBy=multi-user.target
Enable and start the service.
sudo systemctl enable --now code-push-server
If you are using a different web server, consult the relevant documentation for instructions on reverse proxy setup. By default CodePush server is not accessible from public. This VirtualHost configuration will make it publicly accessible.
# Desc: Self-hosted CodePush server.
# Ref: https://github.com/microsoft/code-push-server/blob/main/api/README.md
<VirtualHost *:80>
ServerName example.com
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
CustomLog logs/example.com-access.log combined
ErrorLog logs/example.com-error.log
</VirtualHost>
Prerequisites:
NodeJS installed
NPM installed
Already checkout code to /opt/code-push-server
Build the app.
cd /opt/code-push-server/cli
sudo npm install
sudo npm run build
sudo npm install -g
It will install an executable at /usr/local/bin/code-push-standalone. Follow the rest of the instruction to configure CodePush server: https://github.com/microsoft/code-push-server/tree/main/cli#getting-started