How do you move your NodeJS/Python program to Serverless

Jay Liu
2 min readMay 18, 2019

Go to website console.zhonghuacloud.com:

  1. Zip your existing source code files and folders.
  2. Click the Move to Serverless button
  3. Enter your own domain name which is a dns cname record with the value of host.us.zhonghuacloud.com or you can choose a free sub domain name pattern with xxx.v.zhonghuacloud.com such as abc.v.zhonghuacloud.com
  4. Choose the language of your program(NodeJS/Python).
  5. Choose whether you want to have a free MySQL database or not.
  6. Choose your program is stateful or stateless. (if Your program using server side memory such as http session, then you should choose stateful otherwise choose stateless.)
  7. Click the create website button.
  8. Go to created website and upload the zipped source files.
  9. Click the NPM install / pip install link to build the runtime environment.
  10. Click the startup link to start up your website.(Default there are 2 server instance each website)
  11. (The most valuable feature)Click the scale button to increase or decrease the number of website instances.
  • Caveats:
  1. All instances of your website sharing one filesystem, so your progarm can always save data into the local filesystem safely.
  2. If your website is stateful, the http requests from same customer always hit same website instance safely.
  3. If your website is stateless, the http requests will be load balanced to different website instances.
  4. Your website should listen on the port number 9000. The public traffic will be only forwarded to port number 9000.
  5. The NodeJS program will be booted from the package.json start script, which is from the command npm start
  6. The python program will be started from a shell script named ‘startup.sh’ which is generated by platform. You are free to change the content of the shell scrcipt as you wanted.
  7. You can alway access your mysql database by clicking the link which points to a mysql adminer.php program.
  8. If your program is created with a free MySQL database. The Database connection information can be read from following env variables. This is an example code of NodeJS:

var env = process.env;

var dbo = {

host: env[‘bebox_mysql_host’], port: env[‘bebox_mysql_port’],

user: env[‘bebox_mysql_user’],

password: env[‘bebox_mysql_password’],

database: env[‘bebox_mysql_database’]

};

Any Issue please contact Jay.
jaynsw@wechat
jaynsw@Facebook Messenger
jaynsw@twitter

--

--