#!/usr/bin/env python import os, sys if not 'SMC' in os.environ: os.environ['SMC'] = os.path.join(os.environ['HOME'], '.smc') data = os.path.join(os.environ['SMC'], 'local_hub') if not os.path.exists(data): os.makedirs(data) elif sys.argv[1] == 'start': for x in os.listdir(data): try: os.unlink(os.path.join(data, x)) except: pass path = os.path.split(os.path.realpath(__file__))[0] + '/..' target = os.path.abspath(os.path.join(path, 'local_hub.coffee')) # concatenate all additional arguments and pass them to the node.js server local_hub_args = ' '.join(sys.argv[2:]) cmd = "forever %s -c coffee -l $SMC/local_hub/local_hub.log --pidFile $SMC/local_hub/local_hub.pid -p $SMC/forever/ %s %s"%(sys.argv[1], target, local_hub_args) os.system(cmd)