Comments (5)
I created this for Ubuntu, modify where needed:
############### CONFIGURATION ##################
#! /bin/sh
# path to app
APP_PATH=<PATH/TO/C9>
# path to python bin
DAEMON=/usr/bin/nodejs
# startup args
DAEMON_OPTS=" server.js --port <PORT> -a <USERNAME>:<PASSWORD>"
# user
RUN_AS=<USERNAME>
PID_FILE=/var/run/c9.pid
############### / END OF CONFIGURATION ##################
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo "Starting Cloud9"
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
;;
stop)
echo "Stopping Cloud9"
start-stop-daemon --stop --pidfile $PID_FILE
;;
restart|force-reload)
echo "Restarting Cloud9"
start-stop-daemon --stop --pidfile $PID_FILE
sleep 15
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
;;
*)
N=/etc/init.d/c9
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0```
from core.
i wrote this
#!/bin/sh
### BEGIN INIT INFO
# Provides: node_debian_init
# Required-Start: $remote_fs $named $syslog
# Required-Stop: $remote_fs $named $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Cloud9 IDE initscript for node.js servers
# Description: Cloud9 IDE initscript for node.js servers
### END INIT INFO
# Author: 6api.com <6api.com>
# ______________________________________________________________________________
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DAEMON_ARGS="/usr/local/cloud9/server.js --packed -p 8181 -l 127.0.0.1 -w /root -a : "
DESC="Cloud9 Server"
NODEUSER=root:root
LOCAL_VAR_RUN=/var/run
NAME=node
DAEMON=/usr/bin/node
PIDFILE="/var/run/cloud9.pid"
SCRIPTNAME=/etc/init.d/cloud9
# Exit if the package is not installed
[ -x "$DAEMON" ] || { echo "can't find Node.js ($DAEMON)" >&2; exit 0; }
. /lib/init/vars.sh
. /lib/lsb/init-functions
VERBOSE=yes
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $NODEUSER --background --exec $DAEMON --test > /dev/null \
|| { [ "$VERBOSE" != no ] && log_daemon_msg " already running" ; return 1; }
# start-stop-daemon --start --quiet --chuid $NODEUSER --make-pidfile --pidfile $PIDFILE --background --exec $DAEMON -- \
# $DAEMON_ARGS \
# || { [ "$VERBOSE" != no ] && log_daemon_msg " could not be start" ; return 2; }
start-stop-daemon --start --chuid $NODEUSER --make-pidfile --pidfile $PIDFILE --background --exec /bin/bash -- \
-c "exec $DAEMON $DAEMON_ARGS 1> /var/log/cloud9.out.log 2> /var/log/cloud9.err.log" \
|| { [ "$VERBOSE" != no ] && log_daemon_msg " could not be start" ; return 2; }
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
[ "$VERBOSE" != no ] && log_daemon_msg " started"
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --chuid $NODEUSER --name $DAEMON
RETVAL="$?"
#[ "$VERBOSE" != no ] && [ "$RETVAL" = 1 ] && log_daemon_msg " ---> SIGKILL failed => hardkill $DESC" "$INIT_SCRIPT_NAME_NOEXT"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/3/KILL/5 --pidfile $PIDFILE --chuid $NODEUSER --exec $DAEMON -- $DAEMON_ARGS
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
[ "$VERBOSE" != no ] && [ "$RETVAL" = "1" ] && log_daemon_msg " not running"
[ "$VERBOSE" != no -a "$RETVAL" = "0" ] && log_daemon_msg " stopped" return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --quiet --signal 1 --pidfile $PIDFILE --chuid $NODEUSER --name $NAME
return 0
}
#
# Function that returns the daemon
#
do_status() {
#
# http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
# 0 program is running or service is OK
# 1 program is dead and /var/run pid file exists
# (2 program is dead and /var/lock lock file exists) (not used here)
# 3 program is not running
# 4 program or service status is unknown
RUNNING=$(running)
# $PIDFILE corresponds to a live $NAME process
ispidactive=$(pidof $NAME | grep `cat $PIDFILE 2>&1` >/dev/null 2>&1)
ISPIDACTIVE=$?
if [ -n "$RUNNING" ]; then
if [ $ISPIDACTIVE ]; then
log_success_msg "$DESC is running"
exit 0
fi
else
if [ -f $PIDFILE ]; then
log_success_msg "$DESC is not running, phantom pidfile $PIDFILE"
exit 1
else
log_success_msg "no $DESC instance found"
exit 3
fi
fi
}
running() {
RUNSTAT=$(start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $NODEUSER --background --exec $DAEMON --test > /dev/null)
if [ "$?" = 1 ]; then
echo y
fi
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
status)
do_status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
exit 0
from core.
Are the benefits of a large script like yours? Just curious if I can update my script.
By the way; I would not run it as the root user ..
I call the init.d with sudo, but it will be ran as my default user which is also the owner of my projects and stuff.
from core.
i use this script on my production servers, it's running perfect.
i run it as the root user then i can do anything in browser when I was in travel :)
so i do not need xshell or putty, just a browser.
for security, listen on 127.0.0.1 and use nginx proxy with deny/allow ip.
and after this, i use CloudFlare then my cloud9 have full free ssl and great speed.
here is my nginx conf file.
upstream cloud9 {
server 127.0.0.1:8181;
keepalive 8;
}
server {
listen 80;
server_name ide.example.com;
include common/cloudflare.conf;
location / {
satisfy all;
allow MYIP1;
allow MYIP2;
deny all;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://cloud9/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
from core.
@CrxDelSol @6api thanks for examples of init.d scripts.
I think this can be closed now.
from core.
Related Issues (20)
- Self hosted --collab share error
- Failed to install SDK in Mac OS 10.14.3 HOT 1
- Error creating TMUX session: Cannot read property 'on' of undefined HOT 3
- hide toolbar
- Full Java support?
- Is this project dead? HOT 9
- no more update? HOT 2
- Vulnerabilities
- Can i integrate cloud9 ace editor separately
- Fresh install - git extension not working
- List of flags HOT 2
- Connect to the IDE from a subdomain? HOT 2
- Require password to access Theia in browser?
- connect to SSH workspace from self hosted c9 SDK
- Error: Cannot find module 'c9/urls'
- Python 2 out of support. HOT 1
- Failed to write to 'state.settings'. options.stream must be readable. HOT 8
- How to delete cloud9?
- C9 Sudden stop,
- download and parse revision history
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.